I have followed the steps on A2's tutorial for "Cannot GET" URL here:
https://www.a2hosting.com/kb/cpanel/cpanel-software/node-js-application-error-message-cannot-get-url
The main page, mydomain.com, loads fine and the CSS loads as well but
when I try to go anywhere else, like mydomain.com/port or mydomain.com/anythingelse, I get a 404 error (pic below).
The ejs and CSS templates are in the same file location, and if I change the "/" route to the other page's .ejs/.css that loads just fine so it is finding those routes, but for some reason no other URL routes besides "/" load.
mydomain.com - loads perfectly fine
mydomain.com/anythingelse - the 404 error
This is my app.js:
const express = require("express")
const app = express()
const path = require("path")
const cors = require('cors')
app.use(cors())
app.set("views", path.join(__dirname, "views"))
app.set("view engine", "ejs")
app.use("/test1/static", express.static("public/"))
app.get("/", function (req, res) {
res.render("home-visitor")
})
app.get("/port", function (req, res) {
res.render("port")
})
app.listen()
I have kept my Applicaiton URL blank on purpose so I have a clean home page address
I have tried using a non-blank Application URL and change the app.js file to match syntax accordingly with no difference in outcome (tried '/test/port/', '/test/port', 'test/port/', 'test/port'
This is what I find in the console under Network>post>Headers when I try to load the page on mydomain.com/port
Thanks for any help, I am still new to node.js being hosted with A2 Hosting so I am hoping I am missing something simple.
question from:
https://stackoverflow.com/questions/65837567/node-js-with-a2-hosting-error-404-when-loading-mydomain-com-anyotherpage 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…