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

fix: allow cross origin loading for graphiql #775

Merged
merged 1 commit into from
Apr 25, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions static/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const importer = {
const script = document.createElement('script')
script.type = 'text/javascript'
script.src = url
script.crossOrigin = 'anonymous'

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor point, but the actual name of the property is 'crossorigin' (all lower case).

I know the camel case version works, and I know that html attribute names are case-insensitive, but I think I'd prefer to use the casing indicated by the spec.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to MDN, the proper name is crossOrigin when we refer to it from JS https://developer.mozilla.org/en-US/docs/Web/API/HTMLScriptElement
The fix won't work if the casing is changed to all lower case.

script.addEventListener('load', () => resolve(script), false)
script.addEventListener('error', (err) => reject(err), false)
document.body.appendChild(script)
Expand Down Expand Up @@ -45,6 +46,7 @@ function importDependencies () {
link.type = 'text/css'
link.rel = 'stylesheet'
link.media = 'screen,print'
link.crossOrigin = 'anonymous'
document.getElementsByTagName('head')[0].appendChild(link)

return importer.urls([
Expand Down