(Solution for AWS API Gateway error: ...has been blocked by CORS policy: No Access-Control-Origin header is present on the requested resource)
[ Ссылка ]
When applying the above instructions to ANY method in proxy integration, any applicable CORS headers will not be set. Instead, your backend must return the applicable CORS headers, such as Access-Control-Allow-Origin header
[ Ссылка ]
import json
def lambda_handler(event, context):
return {
'statusCode': 200,
'headers': {
'Access-Control-Allow-Headers': 'Content-Type',
'Access-Control-Allow-Origin': '[ Ссылка ]',
'Access-Control-Allow-Methods': 'OPTIONS,POST,GET'
},
'body': json.dumps('Hello from Lambda!')
}
public class ResponseRest {
String body;
Integer statusCode;
Map <String, String> headers = Map.of("Access-Control-Allow-Origin","*");
Ещё видео!