It seems query parameters are being stripped off the URL when using nextjs redirects.
If you add something like this to the next.config.js
module.exports = {
async redirects() {
return [
{
source: '/one',
destination: '/newplace',
permanent: true,
},
{
source: '/two/:path*',
destination: '/newplacetwo/:path*',
permanent: true,
},
]
},
};
Then test running nextjs in development mode it passes the query parameters along as per the documentation:
curl --head http://localhost:3000/one\?x\=1
HTTP/1.1 308 Permanent Redirect
Location: /newplace?x=1
Then deploy via tf-next and test:
curl --head https://d3il86aqaEXAMPLE.cloudfront.net/one\?x\=1
HTTP/2 308
content-length: 0
server: CloudFront
date: Thu, 07 Apr 2022 22:40:07 GMT
cache-control: public,max-age=31536000,immutable
location: /newplace
Same if we use the :path* redirect. Locally in nextjs:
curl --head http://localhost:3000/two/tree\?x\=2
HTTP/1.1 308 Permanent Redirect
Location: /newplacetwo/tree?x=2
and no query string when deployed via tf-next:
curl --head https://d3il86aqaEXAMPLE.cloudfront.net/two/tree\?x\=1
HTTP/2 308
content-length: 0
server: CloudFront
date: Thu, 07 Apr 2022 22:38:23 GMT
cache-control: public,max-age=31536000,immutable
location: /newplacetwo/tree
It seems query parameters are being stripped off the URL when using nextjs redirects.
If you add something like this to the
next.config.jsThen test running nextjs in development mode it passes the query parameters along as per the documentation:
Then deploy via tf-next and test:
Same if we use the
:path*redirect. Locally in nextjs:and no query string when deployed via tf-next: