具有不同路径的代理下的Next.js

node.js React.js

阿飞

2020-03-24

使用next.js版本,8.0.3我不知道如何在具有不同子路径的代理下提供自定义服务器。

我正在做:

npm run build && npm start

为了构建并打开自定义服务器。

而且,我使用的是带有另一个子路径http:// localhost:8000 / example的代理,而不是打开http:// localhost:3000

代理很简单,可以重现它:

proxy.js

const express = require('express')
const proxy = require('http-proxy-middleware')

const options = {
  target:'http://localhost:3000/',
}
const exampleProxy = proxy(options)
const app = express()

app.use('/example', exampleProxy)
app.listen(8000)

接着:

node proxy.js

但是,当我打开http:// localhost:8000 / example url时,正在加载主页,但没有样式,静态变量,javascript ...任何内容...

如何正确执行?

非常感谢!

第3568篇《具有不同路径的代理下的Next.js》来自Winter(https://github.com/aiyld/aiyld.github.io)的站点

0个回答

问题类别

JavaScript Ckeditor Python Webpack TypeScript Vue.js React.js ExpressJS KoaJS CSS Node.js HTML Django 单元测试 PHP Asp.net jQuery Bootstrap IOS Android