The request for http://localhost:3000/dashboard/js/appclient.js was unsuccessful and returned a 404 (Not Found) error

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!", 
    }
})

Folder Structure

Answer №1

It appears that you are using a route relative to the current URL, which may not be effective in this situation. Assuming you have exposed the 'public' directory using express.static, the js files should be accessed using an absolute route like /js/appclient.js.

<script type="module" src="/js/appclient.js" defer></script>

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

iPhone experiencing no response to HTTPS AJAX request

$(function () { var apiEndpoint = "https://www.myaddress.com/api/"; var getVersion = $.ajax({ url: apiEndpoint + "version/", dataType: "JSON", username: "myuser", type: "GET", password: "mypass" }); ...

AJAX reconstructs accordion elements and shatters them apart

I've implemented Search & Filter Pro to sort through images on a website. The checkbox filters are contained within accordions. Initially, everything functions correctly when the page loads. However, an issue arises when I click on a filter as it ...

Transfer various field values to jQuery

I am looking to send multiple field values to jQuery for validation, but currently only receiving the value of the changed field. How can I pass both field values to jQuery? Enter some text: <input type="text" name="txt1" value="Hello" onchange="myF ...

Display an image when hovering over a list in HTML, utilizing JS and JQuery

When I hover over the text, I want those images to become visible. However, it seems that only the first image is selected because they all have the same ID. Does anyone know how to solve this issue? This is my first post, so please forgive me if I made ...

Loading components dynamically with axios is a valuable feature

Can this be achieved? There is a spinner component. axios: action() { SPINNER (component) -- activate axios.get('/store', { params: { something } }) .then ((resp) => { SPINNER (component) -- ...

Protractor struggling to drag an element, but cannot successfully drop it

I've been utilizing Protractor to test my AngularJS application, specifically focusing on dragging an element and dropping it onto an SVG. So far, I've managed to successfully click and drag the element over the SVG. browser.actions() .mouse ...

Changing the information entered into a form within a subcomponent will result in all other fields being reset

I encountered an issue with my application that involves a form contained within a child component. The parent passes a prop (wizardData) to the child component. If the form is being used to input new data, the field values in the prop will be null; but if ...

Extract information from a JSON string and present it on the screen

I am a complete novice when it comes to D3 (with very little experience in JS). Here are the lines of code I am working with: <script type='text/javascript'> data ='{"mpg":21,"cyl":6,"disp":160,"hp":110,"drat":3.9,"wt":2.62,"qsec":16. ...

Which is the better choice for accessing and manipulating JSON files – using Ajax or the Node fs module?

When storing quiz questions using JSON data, should I use vanilla AJAX or Node.js file system to read the file? I am planning to develop a website where users can create quizzes and save them as JSON. I intend to utilize the Node.js fs module to save the ...

The variable that was posted is not being successfully transferred within the query

There seems to be an issue with retrieving data from the ajax call in ajaxcall.php and assigning it to $place = $_POST['place']; in listplace.php. Despite this problem, the code runs smoothly otherwise. I've tried numerous times to get the ...

Error: Order placement failed due to a validation error

I've been working on developing an ecommerce application, and while the frontend is complete, I've encountered a problem when placing an order. After going through all my files, I couldn't pinpoint where the issue was originating from. Despi ...

The potential for incorporating responsive content from REST APIs into Nuxt-generated static HTML pages is an exciting possibility

Working extensively with Vuejs as a Single Page Application (SPA) has proven to be very beneficial. Vue fulfills numerous requirements and is widely popular. Despite its strengths, there have been challenges related to SEO and social media integration. To ...

Deleting object property within Angular ng-repeat loop

I have information structured like this: $scope.cart={"4": {"cost": 802.85, "description": "test", "qty": 1}, "5": {"cost": 802.85, "description": "test", "qty": 1}}; My goal is to iterate through this data and show it with a remove button. How can I s ...

Implementing a dynamic navigation bar that expands and collapses on mouse hover in a React application

I have a side navigation bar on my webpage that I obtained from a React Bootstrap website, so the class names are already pre-loaded. Instead of using a toggle hamburger icon to expand or collapse the navigation, I want to achieve this functionality based ...

Learning how to send a REST request from an AngularJS client to a Python server

Is there an example available for using REST to get and post data between a Python server and AngularJS client? I am looking for sample code for both the client-side (AngularJS) and server-side (Python). var student_id = 12 $http({ method:"POST", // o ...

Challenge encountered while processing JSON data

I've searched through various threads and tutorials, but I'm still stuck on this issue! I have two JSON responses that need to be utilized in separate functions: 1st (single element) Need to extract "Intention_category" and "count" Data: { " ...

Guide to launching Node Media Server application on Heroku

Currently in the process of deploying a NodeJS live streaming server on Heroku utilizing an RTMP server with node-media-server and socket.io. The challenge I'm encountering is initializing the node-media-server, as it requires 2 ports to run based on ...

Assigning index values to child rows in AngularJS: a step by step guide

One of my requirements involves assigning index values to child rows. The structure includes group rows with child rows underneath. Currently, I am using ng-repeat along with $index for the children as shown below: HTML code: <table ng-repeat="nod ...

Calculating the total sum of choices within select2

Currently utilizing Select2, a jQuery library, to generate a dropdown list. Trying to determine how to accumulate the values of each option selected by the user. Here's the code sample: <!DOCTYPE html> <html> <head> <m ...

Guide on combining two different geoJSON feature collections into two separate layer groups

Currently, I am in possession of two geoJSON feature collections that require integration into the map. Additionally, I desire for these features to be easily toggled on and off through the layer visibility controllers, similar to the demonstration provide ...