1

I've deployed a very basic Express app through Claudia JS. It's working pretty well, but any links or redirects don't keep the API Gateway stage and so don't work.

For example I have the app deployed at http://example.execute-api.eu-west-2.amazonaws.com/production - that's the equivalent of http://localhost:3000 when running locally. If there is a link on that page along the lines of <a href="/test"> that goes to http://localhost:3000/test locally, but through the api gateway it goes to http://example.execute-api.eu-west-2.amazonaws.com/test - losing the /production part of the URL and therefore not working.

Is there a way to get Express to know that all routes need to be prefaced with /production?

The alternate solution is to use a custom domain, but that seems like a lot of hassle to solve what seems like it should be just a bit of config.

kiml42
  • 638
  • 2
  • 11
  • 26

1 Answers1

0

You can use something like this to build the base URL;

https://${req.apiGateway.event.headers.Host}/${req.apiGateway.event.requestContext.stage}

Gonz
  • 1,198
  • 12
  • 26