I have seen posts about this but no questions or answers that match my problem closely enough to provide a valid answer.
I can not send requests to the API through my browser.
The problem, as far as I understand is that when you send a request to the API-gateway; the browser will first send a preflight options request. this preflight request will not add any custom headers ie: x-apigw-api-id
header. This then causes a 403 to be returned without even hitting the options request.
My understanding is that the client has no control over the preflight request, it is handled by the browser.
The get request works through postman and so does the options request but only if I add the x-apigw-api-id
header for each request.
headers returned through postman with x-apigw-api-id
added to request
{"Access-Control-Allow-Origin":"*","Access-Control-Allow-Methods":"GET,OPTIONS","Access-Control-Allow-Headers":"Content-Type,X-Api-Key,","Content-Type":"application/json"}
I remove the header I get a 403 forbidden
.
Is there a workaround for this problem? perhaps not needing the x-apigw-api-id when sending an options request?
Some of the questions I looked up prior to posting: