Redoc: Getting `Error downloading NetworkError when attempting to fetch resource.`

Created on 3 Feb 2019  路  6Comments  路  Source: Redocly/redoc

I run redoc from the docker image with sudo docker run -p 8001:80 -e SPEC_URL=http://localhost:8002/pikatrack-openapi.yaml redocly/redoc but when I load it in the browser I get
Error downloading http://localhost:8002/pikatrack-openapi.yaml NetworkError when attempting to fetch resource..

However if I check the network tab I see it has loaded fine.

screenshot from 2019-02-03 14-50-16

If I change the url to the a different openapi from the internet it loads fine.

All 6 comments

Same issue here. I serve my JSON file on localhost (http://localhost/openapi.json) and it works fine, but when I try to use this URL as 'spec-url', I have the same error.

No problem with online JSONs, it's only for localhost.

Most likely it is CORS-related issue. Add CORS headers to the spec resource.

@RomanGotsiy I don't think so but I may be wrong. If it was CORS I would expect to see the CORS preflight request and then the main request fail due to the preflight not returning.

Can you provide any further details? Are there any errors in the console?
I have no idea where to look.

Maybe you can share your deployment or create a minimal reproducible sample?

I am getting a similar error:
JSON document is publicly available here: https://s3.amazonaws.com/raytio-docs/oas3.json
HTML document here: http://raytio-docs.s3-website-us-east-1.amazonaws.com/index.html

Error message:
Something went wrong...
Error downloading https://s3.amazonaws.com/raytio-docs/oas3.json NetworkError when attempting to fetch resource.

Stack trace

s/<@https://cdn.jsdelivr.net/npm/redoc@next/bundles/redoc.standalone.js:40:6600
e/https://cdn.jsdelivr.net/npm/redoc@next/bundles/redoc.standalone.js:84:35274
a@https://cdn.jsdelivr.net/npm/redoc@next/bundles/redoc.standalone.js:52:122667
R/<@https://cdn.jsdelivr.net/npm/redoc@next/bundles/redoc.standalone.js:52:122812
c@https://cdn.jsdelivr.net/npm/redoc@next/bundles/redoc.standalone.js:52:126206

ReDoc Version: 2.0.0-rc.2
Commit: 889cbe3

This is CORS issue. I'm getting the following error in my browser console:

Access to fetch at 'https://s3.amazonaws.com/raytio-docs/oas3.json' from origin 'http://raytio-docs.s3-website-us-east-1.amazonaws.com' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.

Try using CORS proxy or add CORS headers to the response.

Check it out in our live demo. Works pretty nice with CORS proxy enabled: http://rebilly.github.io/ReDoc/?url=https://s3.amazonaws.com/raytio-docs/oas3.json

Was this page helpful?
0 / 5 - 0 ratings