如何解决在AWS Amplify中部署应用程序时,路由不适用于Node.js应用程序
我在下面的server.js文件中定义了我的路由-
const express = require("express");
const path = require("path");
//Creating an instance of Express
const app = express();
// Serve only the static files form the pages directory
app.use(express.static(__dirname + "/"));
app.get("/home",function(req,res) {
res.sendFile(path.join(__dirname + "/index.html"));
});
app.get("/logo",res) {
res.sendFile(path.join(__dirname + "/pages/logo.html"));
});
app.listen(process.env.PORT || 3000);
当我在本地运行时,它可以工作。但是,当我使用AWS Amplify部署代码时,它只能加载index.html文件。在server.js文件中定义的路由的其余部分在放大中找不到404。
任何
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。