1 Risposta
- Più recenti
- Maggior numero di voti
- Maggior numero di commenti
1
Your Lambda function needs to return the right headers in the response, for example:
const responseHeaders = {
'Content-Type': 'application/json',
'Access-Control-Allow-Origin': '*',
};
const body = { 'userId': 13232 };
return {
statusCode: 200,
headers: responseHeaders,
body: JSON.stringify(results),
};
You shouldn't have to configure CORS after you add those headers. But if you want to configure CORS on API Gateway then navigate to API Gateway in the console and click to open the API Gateway instance you want to change. Under details for that API Gateway open the side menu and make sure you are under resources, then you can enable CORS for a specific resource such as "/users". If you add methods then you'll need to add another header for Access-Control-Allow-Methods
such as 'Access-Control-Allow-Methods': 'GET'
.
con risposta 2 mesi fa
Contenuto pertinente
- AWS UFFICIALEAggiornata un anno fa
- AWS UFFICIALEAggiornata 2 anni fa
Amazing - thank you.