nelmio / NelmioCorsBundle

Adds CORS (Cross-Origin Resource Sharing) headers support in your Symfony application
https://symfony.com/bundles/NelmioCorsBundle/
MIT License
1.89k stars 108 forks source link

net::ERR_CONNECTION_REFUSED #107

Closed essaghir-m closed 1 year ago

essaghir-m commented 6 years ago

Hi, when i call this url (http://127.0.0.1:8000/user/login) from POSTMAN its done but when i use in a mobile app (in dev) this error appear in console "POST http://127.0.0.1:8000/user/login net::ERR_CONNECTION_REFUSED".

can someone help me please.

nelmio_cors: defaults: origin_regex: false allow_origin: ['*'] allow_methods: ['GET', 'OPTIONS', 'POST', 'PUT', 'PATCH', 'DELETE'] allow_headers: ['Content-Type', 'Authorization'] max_age: 3600 paths: '^/': ~

Request URL:http://127.0.0.1:8000/user/login Referrer Policy:no-referrer-when-downgrade Provisional headers are shown Accept:application/json, text/plain, / content-type:application/json Origin:file:// User-Agent:Mozilla/5.0 (Linux; Android 8.1.0; Android SDK built for x86 Build/OSM1.180201.021; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/61.0.3163.98 Mobile Safari/537.36 {user_name: "admin", password: "123456"}

AxelPariss commented 4 years ago

Hi @essaghir-m

I try this config and it works for me (don't forget to re-run your symfony app)

nelmio_cors:
    defaults:
      allow_credentials: true
      allow_origin: ['*']
      allow_headers: ['Origin', 'X-Requested-With', 'Content-Type', 'Accept']
      allow_methods: ['POST','GET','DELETE','PUT']
      expose_headers: ['*']
      max_age: 0
    paths:
        '^/': ~
hernandobgx commented 4 years ago

Hi @essaghir-m

The same thing is happening to me. Did you fix it?