I've deployed my NextJS app in ECS via CDK. The basePath of my application is let's say '/abc'. I was able to access the server via API gateway without any issues.
Recently, I've added a configuration in NextJS - trailingSlash: true
, which basically redirects any path without a trailing slash to a path ending with trailing slash. I need this for SEO purposes.
After I've made this change, when I deploy my server using a new docker image created, when I access the server via APIGW, I get a 308 permanent redirect issue and the page does not load. This is the behaviour -
- When I hit the path '/abc', I initially get redirected to '/abc/' and then get continuously redirected to '/abc/' itself, hence a permanent redirect.
- When I hit the path '/abc/' directly, I get continuously redirected to '/abc/' itself, hence a permanent redirect.
Now when I try and access the server via the network load balancer, everything works as expected -
- When I hit the path '/abc', I initially get redirected to '/abc/' and then get a 200 response from the server
- When I hit the path '/abc/' directly, I get a 200 response from the server
Why is this happening? Is there a configuration that I would need to change? I can provide additional information as needed.(Please consider that I'm an AWS beginner). Thank you