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

CORS issue on chrome #5

Open
shm0x opened this issue Sep 15, 2023 · 3 comments
Open

CORS issue on chrome #5

shm0x opened this issue Sep 15, 2023 · 3 comments

Comments

@shm0x
Copy link

shm0x commented Sep 15, 2023

When using fetch with credentials to make a request to a separated backend (other url/port), everything works perfectly with Firefox with default configuration (use(cors()))

On Chrome, it seems we need to specify all the default options for it to works:

use(cors({
        credentials: true,
        origin: /localhost.*/,
        allowedHeaders: ['Content-Type', 'Authorization'],
 }))

Any ideas what is causing this?

@bogeychan
Copy link
Collaborator

Hi👋, I could not reproduce it on my end.

The following config is required for both latest Chrome 117.0.5938.63 and Firefox 117.0.1:

cors({
    credentials: true,
    origin: /localhost.*/
})

Here is described why:

Maybe a server was not restarted during your development or a browser cached something.

If you keep having problems with this please send a code snipped to reproduce it.

@thomas779
Copy link

thomas779 commented Dec 24, 2023

Bumping this issue as I'm getting the same issues as OP.

My experience:

  1. Encountered type errors on v0.8.0 (solution: downgrade to v0.7.2)
  2. Encountered CORS issues on Chromium browser; specifically Bravew w/ brave shields off, storage cleared & cache cleared (solution: firefox)

If you're using Postman, try removing the 'Host' key in the header and that's the issue AFAIK

@ThomasSchuller
Copy link

Bumping this issue as I'm also getting the same issues.

My experience:
When I have to customize the headers on client e.g. I need to add an authorization header, I get a CORS error.

Tested on both Chrome and Brave with cache disabled.

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

No branches or pull requests

4 participants