Comments (9)
@TrkiSF2 @Seldaek Hi guys, please ignore my previous message...
I struggled the whole day trying to find the problem, accusing my configuration, a bug in this bundle (sorry!), my Apache configuration, and even my browsers and other things, well everything to discover that the problem comes from the proxy used in my company, which silently removes the Access-Control-Allow-Origin
header (and some other ones because it's so much more fun).
My phone connection solved the problem, exactly the opposite to @TrkiSF2 's problem
I tried everything, did a lot of debug in the NelmioCorsBundle
that I know pretty well now, and I can definitely tell it's not a problem of this bundle, which is great by the way!
So this issue can be closed for sure, at least we have learnt this!
from nelmiocorsbundle.
The response does not contain the header Access-Control-Allow-Origin
, because it's overwritten in the htaccess, so the preflight request fails.
You dont have to set headers with apache, because the bundle does this automatically if it's a CORS request. If the origin of the request is http://127.0.0.1:9000
, the bundle sets the header in the response as Access-Control-Allow-Origin: http://127.0.0.1:9000
.
Simply remove all the 'Header set' from the htaccess, and you should be fine.
If the error persist, maybe is related to angular.
from nelmiocorsbundle.
still the same... it seems like the preflight request OPTIONS is failing because of some header or something hm..
BTW: for my API on server I am using FOSRestBundle
fos_rest:
param_fetcher_listener: true
view:
view_response_listener: 'force'
formats:
xml: true
json: true
templating_formats:
html: true
format_listener:
rules:
- { path: ^/api, priorities: [ json, html, xml ], fallback_format: ~, prefer_extension: true }
- { path: '^/', priorities: [ '*/*'], fallback_format: html, prefer_extension: true }
exception:
codes:
'Symfony\Component\Routing\Exception\ResourceNotFoundException': 404
'Doctrine\ORM\OptimisticLockException': HTTP_CONFLICT
messages:
'Symfony\Component\Routing\Exception\ResourceNotFoundException': true
allowed_methods_listener: true
body_listener: true
from nelmiocorsbundle.
@TrkiSF2 still no luck with this? If not it'd be great to dig into https://github.com/nelmio/NelmioCorsBundle/blob/master/EventListener/CorsListener.php#L51 to see where it aborts and why. From looking at your config it seems fine but maybe I'm missing something, or maybe you hit a bug.
from nelmiocorsbundle.
Same issue here with standard configuration for NelmioCorsBundle.
I checked the listener and requests are caught by the listener, the Access-Control-Allow-Origin
header is correctly set in it with the request origin, but still, I get this error as well and can't understand why...
from nelmiocorsbundle.
@Seldaek uphhh I don't remember exactly how I solved it or if it was solved by itself because I don't have this problem now but I would guess two things:
- Maybe there was a problem on front-end with sending request with angularJS but I think it wasn't that.
- Maybe the problem was somehow magically in the network? I remember I was doing a hotspot from mobile device... connecting to it from laptop and then running server on laptop... I am really not sure if a problem could be here or it was related to some other issue but I know when I started to use a router instead of mobile device one error of mines disappeared which sounds kind of funny...
from nelmiocorsbundle.
@Seldaek It seems that the problem is not the same as @TrkiSF2 one. I really don't understand why it's happening for me:
- I digged into the
CorsListener.php
file, added some debug, and theAccess-Control-Allow-Origin
is added with the correct origin - I don't have any Apache setup in some
.htaccess
file concerning headers
Still, the Access-Control-Allow-Origin
is said not be found... It looks like it is set but ignored in some way. I tried to play with the expose_headers
configuration, but with no luck as well.
I tried to install my app on an other server, same thing happens.
This is probably not due to a NelmioCorsBundle
bug, but maybe something else.
from nelmiocorsbundle.
@michaelperrin I am glad you fixed your problem! :) So my theory about network is maybe correct haha :) BTW if you are looking for a new mate in your "network" follow me on twitter https://twitter.com/TrkiSF2. I would like that ;)
from nelmiocorsbundle.
Alright thanks for the updates guys, I'm closing this then.
from nelmiocorsbundle.
Related Issues (20)
- https POST request has blocked by CORS policy HOT 6
- PHP Fatal error HOT 3
- Reflected XSS vulnerability
- 400 Bad request on Preflight (CORS Preflight Did Not Succeed) - Symfony 4 HOT 4
- Symfony 5: 502 Bad Gateway HOT 1
- Allow multiple domains for X-Frame-Options (clickjacking) HOT 1
- NelmioCorsBundle not setting ALLOW_ORIGINS (Heroku Server) HOT 2
- Automatic added Vary-header blocks vary-config from SensioFrameworkExtraBundle-annotation HOT 2
- Symfony 6 compatibility HOT 4
- No 'Access-Control-Allow-Origin' header only for some clients HOT 5
- missing CORS header 'Access-Control-Allow-Origin' Front-End REACT, Back-End Symfony 5 with Api Platform and NelmioCorsBundle HOT 13
- Is this project/repository abandoned? HOT 2
- version 2.3.0 blocks use of psr/log:3.0.0, which the latest version of monolog/monolog requires HOT 2
- POST Request returns 400 with wrong Headers HOT 2
- Symfony 7 support HOT 5
- ERR_ABORTED 500 Response to preflight request doesn't pass access control check: It does not have HTTP ok status HOT 1
- allow_credentials: true is ignored
- Usage of logger within the bundle HOT 2
- How to inject logger into CorsListener?
- Question: multiple allow_origin entries
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nelmiocorsbundle.