ACPixel
08/26/2021, 9:18 AM<http://api.example.com|api.example.com>
and a web page at <http://example.com|example.com>
I have a few routes setup, and for the most part everything works fine. However, specifically PATCH
and PUT
requests from the web page to the sst API fail from cors preflight request. DELETE
works fine however which weirded me out a bit. If there's any blatantly obvious thing I'm missing that would be a huge help!
I do have an OPTIONS
route setup as well, that returns an access-control header, as well as on the API construct I have the cors options with the allowed methods and the allowed origins array, with <https://example.com>
in the allowed originRoss Coundon
08/26/2021, 10:03 AMACPixel
08/26/2021, 10:29 AMcors: {
allowOrigins: [`${process.env.DASH_URI!}`],
allowCredentials: true,
},
And both the options handler and the PATCH handler have
headers: {
"Access-Control-Allow-Origin": process.env.DASH_URI!,
"Access-Control-Allow-Credentials": true,
}
in their responses, so yes, I think I am?ACPixel
08/26/2021, 10:30 AMRoss Coundon
08/26/2021, 10:47 AMcors: {
allowHeaders: [' your headers']
allowOrigins: ['your origins'],
allowMethods: [CorsHttpMethod.GET, <http://CorsHttpMethod.POST|CorsHttpMethod.POST>, CorsHttpMethod.DELETE, CorsHttpMethod.PATCH, CorsHttpMethod.OPTIONS],
},
ACPixel
08/26/2021, 11:01 AMACPixel
08/26/2021, 11:03 AMACPixel
08/26/2021, 11:04 AMRoss Coundon
08/26/2021, 11:05 AM['X-Amz-Date', 'Authorization', 'X-Api-Key', 'X-Amz-Security-Token', 'X-Amz-User-Agent', 'content-type'];
ACPixel
08/26/2021, 11:07 AMACPixel
08/26/2021, 11:07 AM