Fork me on GitHub
#pedestal
<
2019-10-25
>
hadils19:10:28

Hi everyone. I am having trouble with AWS API Gateway and CORS in Pedestal. I am not sure how to make it work...

hadils19:10:45

I have added the ::http/allowed-origins to the service-map but this is not working for me...

Joe Lane19:10:02

@hadilsabbagh18 Are your aws api's using an authorizer?

hadils19:10:18

No, should they>

Joe Lane19:10:16

So, to be clear, this api is an unauthed api? Are you using ions/http-direct?

hadils19:10:38

No, lambda. This is an unathed api.

Joe Lane19:10:32

So it's pedestal running in a JVM Lambda?

hadils19:10:08

When I call it from an S3 website, it is returning 404 errors.

hadils19:10:24

I have listed the domain name as an allowed origin.

Joe Lane19:10:34

@hadilsabbagh18 On the apigateway resource have you clicked the "Enable CORS" dropdown?

hadils19:10:59

Yes, I have. And changed from Mock to Lambda proxy integration.

Joe Lane19:10:49

Does your service map contain the secure-headers key?

souenzzo19:10:49

@hadilsabbagh18 I use ::http/secure-headers {:content-security-policy-settings "script-src 'self' 'unsafe-inline' 'unsafe-eval'"}}

hadils19:10:49

@souenzzo What is my-bucket supposed to be set to? My domain or the domain of the caller?

hadils19:10:55

Ok, thanks!

hadils19:10:38

After returning a status code of 200 from my Lambda function, AWS then does this:

(3308d6aa-08fe-40c8-9e24-ac22487b359b) Method response headers: {Access-Control-Allow-Origin=, Access-Control-Expose-Headers=, Content-Type=text/plain, X-Amzn-Trace-Id=Root=1-5db34f42-39cc3ea420f2cc35a7ae7d3c;Sampled=0}
and returns a 404. I have been getting this for four days. Can anyone help me?

Joe Lane20:10:37

Is that response from your lambda or from apigateway?

hadils20:10:37

apigateway

hadils20:10:58

It seems to mask the Lambda output.

Eduardo Mata22:10:18

I have my UI done in react. My backend is done Clojure. I use Pedestal as my server. I deployed my web app. After being deployed, I can access my site. However, If I stay in the page longer than 5 minutes, it comes back with

ErrorPanel.js:36 Request has been terminated
Possible causes: the network is offline, Origin is not allowed by Access-Control-Allow-Origin, the page is being unloaded, etc.

Eduardo Mata22:10:23

this is in my react ui

Eduardo Mata22:10:06

My backend appears to be healthy with no warns/errors. THey run a healthy check heartbeat every 10seconds