1

我不知道如何从 Next.js 重定向中检索原始 URL 请求。实际上,代码在我的本地服务器上按预期工作,但信息在生产中消失了。

我的next.config.ts包括:

{
    source: '/user/:path*',
    destination: '/api/forward/forward',
    permanent: true,
}

在本地运行时,我有以下内容:

...
'postman-token': '4d592b2f-a759-415c-a775-14e838f25d1e',
  'accept-encoding': 'gzip, deflate, br',
  connection: 'keep-alive',
  'content-length': '3',
  referer: 'http://localhost:3000/user/5f8d46425afbfe125bc0277c/balances/2970022',
  host: 'localhost:3000'
...

所以这里一切都很好,我可以使用referer。

不幸的是,我无法从生产中的请求中检索原始 URL;我唯一得到的是:

{
 accept: 'application/json',
 authorization: 'bearer XXXXX',
 'client-id': 'YYYYY',
 'content-type': 'application/json',
 'content-length': '147',
 host: 'www.CCC.com',
 'accept-encoding': 'gzip',
 'user-agent': 'okhttp/4.9.1',
 'x-forwarded-proto': 'https',
 'x-forwarded-port': '443',
 'x-forwarded-for': '176.145.84.153',
 forwarded: 'proto=https;for=176.145.XX.XXX:2112;by=185.42.XXX.XXX',
 'sozu-id': '...'
}

如果有人知道我如何获取初始 URL 以便正确转发,我将不胜感激。

4

0 回答 0