Angular SPA incompatible with ANY access control method using Gateway API

We are currently using a serverless deployment model for our NodeJS codebase API. Everything was fine until we came across a hard limit for CloudFormation stacks created by a server without a server that has a limited resource limit of 200.

Trying to get around this while the Serverless team is working on nested stack integration was replacing GET, PUT, POST, DELETE for the same route with ANY, which saved us about 75% in CloudFormation resources.

The Gateway API seems to have done a good job of this; the integration response for the OPTIONS route returned Access-Control-Allow-Methods: 'OPTIONS,ANY'.

Testing this with the postman worked like a charm, being able to use all the previously mentioned methods without a hitch.

Doing this from our Angular frontend does not seem to work.

XMLHttpRequest cannot load. The PUT method is not allowed by the Access-Control-Allow-Methods methods in the preflight response.

In Angular, the eyes, POST, PUT, DELETE, ... do not match ANY, but for the postman it does.

Any reasons why this might happen are welcome.

UPDATE

The POST request works through the Angular application, only PUT and DELETE requests throw an error "not allowed using Access-Control-Allow-Methods".

+4
source share
2 answers

Updating Serverlessto the version above is 1.10.0fixed. They fixed this error in this problem .

0

OPTIONS Access-Control-Allow-Methods: "OPTIONS, ANY".

CORS, OPTIONS CloudFormation, "Access-Control-Allow-Methods" "DELETE, GET, HEAD, OPTIONS, PATCH, POST, PUT" ' , ANY. ( API Gateway, CORS ). .

0

Source: https://habr.com/ru/post/1675338/


All Articles