我正在尝试重定向此格式的URL:http://localhost:8080/setup/xyz/?code=some-code
更改为:http://localhost:8080/app/#/setup/xyz/?code=some-code
个
我尝试过代理和重写:
historyApiFallback: {
rewrites: [
{ from: /^\/$/, to: '/index.html' },
{ from: /^\/app/, to: '/app.html' },
{ from: /^\/setup/, to: '/app/#/setup' },
]
},
但是它似乎不起作用。有没有办法用dev服务器来写301重定向?
2条答案
按热度按时间zphenhs41#
尝试配置
devServer
https://itsopensource.com/how-to-serve-api-locally-with-webpack/bmp9r5qi2#
@Eugen的回答让我走上了正确的道路。以下是我需要的额外细节:
当前的devserver API是
onBeforeSetupMiddleware
,它公开了express server API,包括重定向。