Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Redoc demo readFile undefined #2009

Closed
ocole007 opened this issue May 13, 2022 · 13 comments · Fixed by #2220
Closed

Redoc demo readFile undefined #2009

ocole007 opened this issue May 13, 2022 · 13 comments · Fixed by #2220

Comments

@ocole007
Copy link

Describe the bug
When we use the "Try It" feature at https://redocly.github.io/redoc/ e.g. https://redocly.github.io/redoc/?url=https://docs.graphhopper.com/openapi.json, an exception is raised.

Expected behavior
The URL passed to redoc should render the based on the swagger JSON description.

Minimal reproducible OpenAPI snippet(if possible)

Screenshots
image

Cannot read properties of undefined (reading 'readFile')
Stack trace
Error: Cannot read properties of undefined (reading 'readFile')
at t.BaseResolver. (https://redocly.github.io/redoc/redoc-demo.bundle.js:2:27238)
at Generator.next ()
at https://redocly.github.io/redoc/redoc-demo.bundle.js:2:25385
at new Promise ()
at r (https://redocly.github.io/redoc/redoc-demo.bundle.js:2:25130)
at t.BaseResolver.loadExternalRef (https://redocly.github.io/redoc/redoc-demo.bundle.js:2:27020)
at t.BaseResolver. (https://redocly.github.io/redoc/redoc-demo.bundle.js:2:27751)
at Generator.next ()
at https://redocly.github.io/redoc/redoc-demo.bundle.js:2:25385
at new Promise ()

ReDoc Version: 2.0.0-rc.68
Commit: 494122f
Additional context

@AlexVarchuk
Copy link
Collaborator

AlexVarchuk commented May 15, 2022

Hi @ocole007, we released the next version 2.0.0-rc.69. It works for me.

Screenshot 2022-05-15 at 11 33 58

Please verify or add additional steps to reproduce(browser version, OS, etc)

@jaaufauvre
Copy link

I'm getting the same error.

@AlexVarchuk
Copy link
Collaborator

Hi @jaaufauvre, can you add me steps to reproduce and some additional information(browser version, OS, screenshot of network tab, etc)

@jaaufauvre
Copy link

Hi @AlexVarchuk,

Edge 101.0.1210.47, Chrome 101.0.4951.64, Brave 101.0.4951.41

Windows 10, Windows 11

✔️ https://redocly.github.io/redoc/?url=https://api.apis.guru/v2/specs/googleapis.com/calendar/v3/openapi.yaml&nocors

https://redocly.github.io/redoc/?url=https://api.apis.guru/v2/specs/googleapis.com/calendar/v3/openapi.yaml

Something went wrong...
Cannot read properties of undefined (reading 'readFile')
Stack trace
Error: Cannot read properties of undefined (reading 'readFile')
    at t.BaseResolver.<anonymous> (https://redocly.github.io/redoc/redoc-demo.bundle.js:2:27238)
    at Generator.next (<anonymous>)
    at https://redocly.github.io/redoc/redoc-demo.bundle.js:2:25385
    at new Promise (<anonymous>)
    at r (https://redocly.github.io/redoc/redoc-demo.bundle.js:2:25130)
    at t.BaseResolver.loadExternalRef (https://redocly.github.io/redoc/redoc-demo.bundle.js:2:27020)
    at t.BaseResolver.<anonymous> (https://redocly.github.io/redoc/redoc-demo.bundle.js:2:27751)
    at Generator.next (<anonymous>)
    at https://redocly.github.io/redoc/redoc-demo.bundle.js:2:25385
    at new Promise (<anonymous>)

ReDoc Version: 2.0.0-rc.68
Commit: 494122f9

image

@AlexVarchuk
Copy link
Collaborator

@jaaufauvre we redeployed the demo page.
Hopes it helps. Please check.

@jaaufauvre
Copy link

Hi @AlexVarchuk, nop it didn't help. It works with Firefox though.

@ocole007
Copy link
Author

Hi @AlexVarchuk , upon further inspection, this could be a CORS issue as I tested without CORS checked and it worked in some instances.

@AlexVarchuk
Copy link
Collaborator

Hi @ocole007. Seems it can be true. We have a special checkbox for it. One of the cases should be working.

@AlexVarchuk
Copy link
Collaborator

I missed it. 🙈
I think it is expected behavior. One of CORS's cases should work.

@AlexVarchuk
Copy link
Collaborator

I close this issue. Because it is expected behavior. The demo page should work in one of the CORS cases (enabled/disabled).

@kiwisincebirth
Copy link

kiwisincebirth commented Jul 6, 2022

@AlexVarchuk - This tread helped me identify an issue that I was having. As a suggestion - It would be good if you handled the error, and correctly reported it in user friendly way - It would simplify the understanding of the issue, and make the tool easier to use. - Great Tool BTW :)

ninsbl added a commit to ninsbl/actinia_core that referenced this issue Sep 15, 2022
The API docs gives only an error currently. Adding `&nocors` aparently helps. (maybe browser dependent?)
See: Redocly/redoc#2009 for background
mmacata pushed a commit to actinia-org/actinia-core that referenced this issue Sep 22, 2022
The API docs gives only an error currently. Adding `&nocors` aparently helps. (maybe browser dependent?)
See: Redocly/redoc#2009 for background
@ayame113
Copy link
Contributor

ayame113 commented Dec 2, 2022

The demo page should work in one of the CORS cases (enabled/disabled).

It looks like this problem still exists.


I've debugged this and it seems that different browsers have different ways of handling the URL constructor.
The code below returns different results.

new URL("\\\\cors.redoc.ly/https://apiland.deno.dev/~/spec", "https://redocly.github.io/redoc/?url=https://apiland.deno.dev/~/spec")

image
image

I think maybe correcting the url in this line from \\\\cors.redoc.ly/ to https://cors.redoc.ly/ will fix the problem.

? '\\\\cors.redoc.ly/' + new URL(specUrl, window.location.href).href

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants