【发布时间】:2018-07-03 16:31:34
【问题描述】:
我在一个 ec2 实例上有一个快速服务器,它有一个 api (/api) 和一个客户端(所有不是 /api 在反应中处理的东西。)
转到http://ip.address:3000 工作正常。它显示了应用程序,一切正常。
但是去https://ip.address(由nginx转发)不能正常工作。它正确加载了我的 index.html,但在所有 /static/bundle.js 和 /static/bundle.css 文件上加载了 404。
nginx
# redirect to node for the dynamic stuff
location / {
proxy_pass https://localhost:8003/index.html;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $host;
proxy_hide_header X-Powered-By;
}
表达
let router: express.Router = express.Router();
router.use(express.static(path.join(__dirname, "/build")));
const api: ApiRouter.Api = new ApiRouter.Api();
router.use("/api", api.router.bind(api.router));
//Catch all for react - client side routing
router.get("*", function(req, res) {
res.sendFile(path.resolve(__dirname, "/build/index.html"));
});
【问题讨论】: