pedestal

hadils 2019-10-25T19:09:28.021300Z

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

hadils 2019-10-25T19:15:45.022300Z

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

Joe Lane 2019-10-25T19:23:02.022900Z

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

hadils 2019-10-25T19:23:18.023100Z

No, should they>

hadils 2019-10-25T19:23:20.023300Z

?

Joe Lane 2019-10-25T19:24:16.024300Z

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

hadils 2019-10-25T19:24:38.024700Z

No, lambda. This is an unathed api.

Joe Lane 2019-10-25T19:26:32.025200Z

So it's pedestal running in a JVM Lambda?

hadils 2019-10-25T19:28:08.026200Z

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

hadils 2019-10-25T19:28:24.026600Z

I have listed the domain name as an allowed origin.

Joe Lane 2019-10-25T19:28:34.026900Z

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

hadils 2019-10-25T19:28:59.027600Z

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

Joe Lane 2019-10-25T19:29:49.028400Z

Does your service map contain the secure-headers key?

hadils 2019-10-25T19:30:04.028900Z

No.

souenzzo 2019-10-25T19:30:49.029700Z

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

hadils 2019-10-25T19:31:18.030Z

Thanks @souenzzo

hadils 2019-10-25T19:32:49.030800Z

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

souenzzo 2019-10-25T19:33:21.031200Z

<https://my-bucket.s3.amazonaws.com>

hadils 2019-10-25T19:35:55.031500Z

Ok, thanks!

hadils 2019-10-25T19:45:38.032800Z

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 Lane 2019-10-25T20:04:37.033200Z

Is that response from your lambda or from apigateway?

hadils 2019-10-25T20:20:37.033400Z

apigateway

hadils 2019-10-25T20:20:58.033800Z

It seems to mask the Lambda output.

Eduardo Mata 2019-10-25T22:25:18.035600Z

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 Mata 2019-10-25T22:25:23.035800Z

this is in my react ui

Eduardo Mata 2019-10-25T22:26:06.036700Z

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