我在Heroku中設置了一個自定義域,效果很好。我可以使用我的應用名稱和自定義域來訪問我的網站。我可以使用標準的Heroku URL訪問路由,但不能使用自定義域。例如:作品:https://{myappname}.herokuapp.comhttps://{myappname}.herokuapp.com/callbackhttps://{customdomain}.com不起作用:https://{customdomain}.com/callback服務器配置:const express = require("express");const path = require("path");;const callback = require("./callback");const app = express();// Body parser middlewareapp.use(bodyParser.urlencoded({ extended: false }));app.use(bodyParser.json());// Serve static assets if in production if (process.env.NODE_ENV === "production") { app.use("/callback", callback);// Set static folder app.use(express.static("client/build")); app.get("*", (req, res) => { res.sendFile(path.resolve(__dirname, "client", "build", "index.html")); });}// Init server/portconst port = process.env.PORT || 5000;app.listen(port, () => console.log(`Server running on port ${port}`));
Node.js中的Heroku自定義DNS API路由問題
九州編程
2021-05-09 09:05:55