Nextjs 重写:浏览器路径修改为目标路径

问题描述 投票:0回答:0

我正在使用 Nextjs 重写从外部网页(不是当前应用程序的一部分)获取内容,并希望保留当前应用程序的 url。但是当我尝试使用

source path
访问该网页时,浏览器成功获取了内容,但也将
source path
替换为
destination path

这是我的代码片段。

rewrites() {
    return [
      {
        source: '/web/:token',
        destination: 'http://localhost:3000/viewer/web/:token'
      }
    ]
  }

注意:当前应用程序运行在端口 3001

例如当我在浏览器中点击

http://localhost:3001/web/123456789
时它获取内容但替换了从
/web/123456789
/viewer/web/123456789

的路径
next.js http-proxy nextjs-rewrites
© www.soinside.com 2019 - 2024. All rights reserved.