aws4-axios
aws4-axios copied to clipboard
Access to XMLHttpRequest at 'https://<AWS-LAMBDA-FUNCTION-URL>' from origin 'http://localhost:3000' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.
Hi,
I'm running into some CORS errors when sending a GET request to my lambda service's function URL. I've tested this request with Postman and it's returning 200 ok. But when I try the same request in the browser it throws a CORS error.
Here's my init code:
export const axios = require('axios').default
import { aws4Interceptor } from 'aws4-axios'
const interceptor = aws4Interceptor(
{
region: 'us-east-1',
service: 'lambda',
},
{
accessKeyId: 'ACCESS-ID',
secretAccessKey: 'SECRET-KEY',
}
)
axios.interceptors.request.use(interceptor)
And then it's just a simple axios.get()
request to the AWS-LAMBDA-FUNCTION-URL
.
Am I missing something?
Thanks!