Git Product home page Git Product logo

Comments (9)

michaelperrin avatar michaelperrin commented on June 1, 2024 1

@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.

Basestcar avatar Basestcar commented on June 1, 2024

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.

EnchanterIO avatar EnchanterIO commented on June 1, 2024

still the same... it seems like the preflight request OPTIONS is failing because of some header or something hm..
screenshot from 2014-07-03 21 54 42

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.

Seldaek avatar Seldaek commented on June 1, 2024

@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.

michaelperrin avatar michaelperrin commented on June 1, 2024

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.

EnchanterIO avatar EnchanterIO commented on June 1, 2024

@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:

  1. Maybe there was a problem on front-end with sending request with angularJS but I think it wasn't that.
  2. 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.

michaelperrin avatar michaelperrin commented on June 1, 2024

@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 the Access-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.

EnchanterIO avatar EnchanterIO commented on June 1, 2024

@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.

Seldaek avatar Seldaek commented on June 1, 2024

Alright thanks for the updates guys, I'm closing this then.

from nelmiocorsbundle.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.