question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Could someone help me with this CORS issue?

See original GitHub issue

Could this issue be resolved with different configuration flag or is this an actual bug or unsupported?

Running http-server with the following:

npx http-server -p 3001 --cors
npx: installed 29 in 3.722s
Starting up http-server, serving ./

http-server settings: 
CORS: true
Cache: 3600 seconds
Connection Timeout: 120 seconds
Directory Listings: visible
AutoIndex: visible
Serve GZIP Files: false
Serve Brotli Files: false
Default File Extension: none

Available on:
  http://127.0.0.1:3001
  http://10.216.156.5:3001
  http://172.17.0.1:3001

When fetching the json files, the preflight check is failing.

[Tue Aug 24 2021 12:36:22 GMT-0400 (Eastern Daylight Time)]  "OPTIONS /monitoring/mon_ui/assets/switch_monitoring_service_meta_data.json?_=1629823501368" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.131 Safari/537.36"
[Tue Aug 24 2021 12:36:22 GMT-0400 (Eastern Daylight Time)]  "OPTIONS /monitoring/mon_ui/assets/switch_overview.json?_=1629823501368" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.131 Safari/537.36"

Errors in browser:

Access to XMLHttpRequest at ‘https://blah.cloudfront.net/monitoring/mon_ui/assets/switch_monitoring_service_meta_data.json?_=1629823501368’ from origin ‘https://app.blah.com’ has been blocked by CORS policy: Request header field authorization is not allowed by Access-Control-Allow-Headers in preflight response.

Access to XMLHttpRequest at ‘https://blah.cloudfront.net/monitoring/mon_ui/assets/switch_overview.json?_=1629823501368’ from origin ‘https://app.blah.com’ has been blocked by CORS policy: Request header field authorization is not allowed by Access-Control-Allow-Headers in preflight response.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
totszwaicommented, Aug 24, 2021

@thornjad authorization resolved the error!!! Thank you.

PS: Wouldn’t it be better when user specify --cors the server should just, by default, make EVERYTHING CORS related to just work? 😃

0reactions
thornjadcommented, Aug 24, 2021

I can see the argument both ways, because allowing everything would make development easier, but is inherently less safe. The way it was built predates my involvement in the project, so I’m not entirely sure on the reasoning for the default allowed headers.

Read more comments on GitHub >

github_iconTop Results From Across the Web

CORS errors and how to solve them - Topcoder
CORS is an abbreviation for Cross-Origin Response Sharing. It is what allows the website on one URL to request data from a different...
Read more >
3 Ways to Fix the CORS Error — and How the Access-Control ...
Fix one: install the Allow-Control-Allow-Origin plugin. The quickest fix you can make is to install the moesif CORS extension .
Read more >
A Guide to Solving Those Mystifying CORS Issues
An 'issue with CORS' occurs when the API does not reply to such request with, 'Yes, dear browser, you are allowed to do...
Read more >
What Is a CORS Error and How to Fix It (3 Ways) - Bannerbear
A CORS error is common when making an HTTP request to another origin. You can get rid of it using one of the...
Read more >
CORS errors - HTTP - MDN Web Docs - Mozilla
In these pages, we'll look into some common CORS error messages and how to resolve them. ... These steps may help you do...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found