sequence icon indicating copy to clipboard operation
sequence copied to clipboard

Cors error

Open Wellers0n opened this issue 4 years ago • 5 comments

I'm with a cors error, can you help me ?

sequence_1  | INFO  io.pedestal.http.cors  - {:msg "cors request processing", :origin "http://localhost:3000", :allowed nil, :line 84}

image

Wellers0n avatar Feb 01 '21 19:02 Wellers0n

Hey @Wellers0n!

Can you share the request you're trying to make and the response you get?

You can set a list of accepted CORS hosts by setting the environment variable: ALLOWED_ORIGINS

For example, setting: ALLOWED_ORIGINS= '["https://decimals.stoplight.io"]' will allow requests from https://decimals.stoplight.io - you can add a list of origins to this array.

Just added this description to the docs, thanks!

andriosrobert avatar Feb 02 '21 23:02 andriosrobert

I need putting this in my file lein.env, right ?

my file lein.env:

{
    ALLOWED_ORIGINS='["http://localhost:3000/"]'
}

it's ok ?

Wellers0n avatar Feb 03 '21 18:02 Wellers0n

it don't work

Wellers0n avatar Feb 03 '21 18:02 Wellers0n

I'm using this service that accept a request from localhost:3000

(def service-map-new
  {::http/routes i/routes
    ::http/allowed-origins {:allowed-origins ["http://localhost:3000"]
                            :methods "GET,POST"}
    ::http/type   :jetty
    ::http/host   "0.0.0.0"
    ::http/port   8910})

but this don't work in my machine :/

Wellers0n avatar Feb 03 '21 18:02 Wellers0n

It will help if you share how you are trying to connect to the API.

The logs aren't showing an error, are you trying to access from the browser?

andriosrobert avatar Feb 10 '21 21:02 andriosrobert