redirect - NextJS 重定向 - req.headers.referer 丢失 - 如何获取原始 URL?
问题描述
我不知道如何从 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 以便正确转发,我将不胜感激。
解决方案
推荐阅读
- javascript - WordPress 发布失败;javascript 显示错误“访问 fetch ... 已被 CORS 策略阻止”
- php - 从另一个变量调用类内的变量
- php - 如何在 CONCAT 中正确使用通配符
- java - 为什么 Rest Assured 说“验证不匹配”,但例外确实匹配实际?
- webpack - 使用 Pug 2 和 Webpack 4,“include”可以正确导入内容,但“extends/block”不会产生任何内容或错误
- formik - Formik Field - 如何对内置的 CSS 进行格式化零件
- python - 如何使用pymongo检查mongoDB中的子属性是否存在
- php - php-fpm 被污染是什么意思?
- html - 是否可以定义一个连接多个选择器并用分号分隔它们的 HTML 选择器?
- r - 如何在R中按月重新采样?