AWS ApiGateway Rest API: Redirect upon integration status code 404

13 Views Asked by At

I have a rest api endpoint integrated with S3 bucket delivering static website content. The website is React SPA using "Create React App" deployed to S3 bucket. A rest API endpoint proxies all request to the bucket. For home page GET '/' points to the index.html and all the rest static files are served by "greedy catch all" method /{item+} proxied to bucket {object}.

When a user wants to access '/dashboard' for example, the api redirects to the bucket then the bucket responds with 404 since there is static asset for the specified path and then api returns the error code. On the web app though there is such page. I want to be able all the S3 404 responses to be redirected to root.

I read that it should be possible to catch and change the response via Mapping templates , but all the examples are with JSON body and I want to forward the body as is (be it text or whatever)

0

There are 0 best solutions below