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

ERR_ABORTED 500 Response to preflight request doesn't pass access control check: It does not have HTTP ok status #195

Open
EliphazBouye opened this issue Dec 21, 2023 · 1 comment

Comments

@EliphazBouye
Copy link

EliphazBouye commented Dec 21, 2023

My nelmio_cors.yaml:
nelmio_cors:

    defaults:
        origin_regex: true
        allow_origin: ['%env(CORS_ALLOW_ORIGIN)%']
        allow_methods: ['GET','POST', 'PUT', 'PATCH', 'DELETE', 'OPTIONS' ]
        allow_headers: ['Content-Type', 'Authorization']
        expose_headers: ['Link']
        allow_credentials: true
        max_age: 3600
    paths:
      '^/api/':
          allow_origin: [*]
          allow_headers: ['*'],
          allow_methods: ['POST', 'PUT', 'GET', 'DELETE', 'OPTIONS']
          max_age: 3600
          hosts: ['^api\.']

my server host address : http://localhost:8000 and my origin address : http://localhost:5174
I got this error :
https://localhost:5174/#/:1 Access to fetch at 'http://localhost:8000/api/auth/me' from origin 'http://localhost:5174' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: It does not have HTTP ok status.
In my terminal I got :

[Web Server ] Dec 21 10:33:00 |WARN   | SERVER OPTIONS (400) /api/auth/me host="localhost:8000" ip="::1" scheme="https"
[PHP        ] [Thu Dec 21 10:33:00 2023] 127.0.0.1:49414 [400]: OPTIONS /api/auth/me
[PHP        ] [Thu Dec 21 10:33:00 2023] 127.0.0.1:49414 Closing
[PHP        ] [Thu Dec 21 10:33:00 2023] 127.0.0.1:49428 Accepted
[PHP        ] [Thu Dec 21 10:33:00 2023] 127.0.0.1:49428 [400]: OPTIONS /api/auth/me
[PHP        ] [Thu Dec 21 10:33:00 2023] 127.0.0.1:49428 Closing

I don't know how to solve it I have clear cache so much time but nothing change.
Someone has already have this issue how to solve it ?

@YgorAlves
Copy link

I got the same issue, did you found any solution?

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

2 participants