Among many similar queries, I am puzzled as to why dashboard.html
is unable to locate appclient.js
, while index.html
can successfully find it.
The error message received is:
GET http://localhost:3000/dashboard/js/appclient.js net::ERR_ABORTED 404 (Not Found)
app.js
// /login redirects the client to /dashboard/:uid if correctly authenticated
app.route("/login")
.get((req,res) => {
res.sendFile('./public/index.html', {root: __dirname})
})
app.route("/dashboard/:uid")
.get((req,res) => {
res.sendFile('./public/dashboard.html', {root: __dirname})
})
app.use(express.static('public'))
index.html
<!DOCTYPE html>
<html lang="de">
<head>
<script type="module" src="js/appclient.js" defer></script>
</head>
<body>
<myapp>
<h1> {{ title }} </h1>
</myapp>
</body>
</html>
dashboard.html
<!DOCTYPE html>
<html lang="en">
<head>
<script type="module" src="js/appclient.js" defer></script>
<title>Dash</title>
</head>
<body>
<h1>dash</h1>
</body>
</html>
appclient.js
import Vue from './lib/vue.esm.browser.js'
import VueResource from './lib/vue-resource.esm.js'
Vue.use(VueResource);
const myApp = new Vue({
name: "myapp",
el: ' myapp',
data: {
title: "Hello World!",
}
})