Vue-Router 4 now automatically redirects the default URL to a "404 Page Not Found

I recently decided to upgrade my Vue application from version 2 to version 3, following the official Vue migration documentation. One of the changes I made was updating the vue-router package. However, after updating my router.js file, I noticed that when running the application locally, it defaults to routing to a 404 page not found component.

Previously, the application was routing to the overview page at http://localhost:8080/overview. Now, this URL leads to the page not found component. Below is a snippet of my updated router.js file:

router.js

    /* [IMPORT] Library */
import { createRouter, createWebHistory } from 'vue-router';
/* [IMPORT] Common module */
import store                  from '~/common/store';
/* [IMPORT] modules */
import devModule              from '~/module/devModule';
import pageNotFoundPage       from '~/page/common/pageNotFound';

/* [IMPORT][PAGE] OverView */
import overviewPage           from '~/page/overview/overviewPage';

const routes = [

        { path: '/'   , redirect: '/dev'},
        { path: '/dev', component: devModule, children: [
            /* Default routing*/
            { path: '', redirect: 'overview/overview'},
            /* OVERVIEW */
            { path: 'overview', redirect: 'overview/overview'},
            { path: 'overview/overview' ,   component: overviewPage}
        ]},
        /* [404] anything else... */
        { path: '/:catchAll(.*)'   , component: pageNotFoundPage },
    ];

    export const router = createRouter({ history: createWebHistory(), routes });

/* [intercepter] */
router.beforeEach(function(to, from, next) {
    // 1. Update current URL :: for store
    store.commit('moveMenu',to.path);
    // x. go to next menu
    next();
});
export default router;

I am puzzled as to why the application is not routing to the overview page after the migration. Any suggestions or guidance on this issue would be greatly appreciated.

Answer №1

To combine the child route path with the parent route, you can do it like this:

http://localhost:8080/dev/overview

For further information, refer to the nested-routes section in the official documentation

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

Learn how to retrieve specific user information from a JSON file by implementing a button click feature within a custom directory using Angular.js

I am just starting to learn angular.js and I'm trying to figure out how to retrieve JSON data from a custom directory. My goal is to display the information of a specific user when a particular button is clicked, but so far I haven't been success ...

One way to achieve the same functionality as onclick in an Ajax call using

I have two JSPs. In the first JSP, I am making an ajax call and receiving data (Ajax body) from the second JSP. However, I am unsure of how to execute jQuery when an argument is present in the function. Everything works fine without an argument. In the ...

My Babel-Loader seems to be failing in converting the vendor code to be compatible with IE8+. What might be causing this issue?

I'm currently utilizing the most recent versions of Webpack, Babel, and Babel-Loader in my Vue.js application. My goal is to ensure that my code runs smoothly on Internet Explorer 8, 9, and 10, but unfortunately, I am facing difficulties with this. ...

`validate.js verifying the elements within an array`

One of the challenges I'm facing in my JavaScript project is dealing with objects that have two array properties included. As part of my development process, I've decided to utilize the resources provided by the validate.js library. To illustrat ...

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 ...

What is the best way to capture a 403 response when making a GraphQL API call?

My server handles component rendering and generates an HTML response upon request. During the rendering process, the server initiates a GraphQL call for a specific component which sometimes results in a 403 error. Here is the code snippet: const client = ...

Sentry alert: Encountered a TypeError with the message "The function (0 , i.baggageHeaderToDynamicSamplingContext) does not

My website, which is built using Next.js and has Sentry attached to it, runs smoothly on localhost, dev, and staging environments. However, I am facing an issue when trying to run it on my main production server. The error message displayed is as follows: ...

Including JavaScript in HTML Error 404

https://i.stack.imgur.com/aQDPG.png I am struggling to understand why this import is not functioning as expected. I have tried using script/import.js but it still fails to work. The error message I keep receiving is: 127.0.0.1 - - [09/Sep/2020 15:09:35] ...

Monitor and adjust variables simultaneously using AngularJS

My goal is to dynamically calculate and display values based on two other variables in real time. I've successfully managed to track one variable, but not both simultaneously. $scope.color_slider_bar = { value:0, minValue: 0, maxValue: ...

Exploring the functionality of CodePen's code editor in relation to developing a 2D shooting game

Recently, I created a straightforward 2D shooter game with all the code neatly organized in a single HTML file: (file_gist). When I tested the game in my chrome browser, everything worked flawlessly according to my intentions. However, upon transferring th ...

Localization of labels and buttons in Angular Owl Date Time Picker is not supported

When using the Owl Date Time Picker, I noticed that the From and To labels, as well as the Set and Cancel buttons are not being localized. Here is the code snippet I am using to specify the locale: constructor( private dateTimeAdapter: DateTimeAdapter&l ...

Send location data to the PHP server through AJAX and then fetch it in JavaScript once it has been handled

I am looking to transfer coordinates from client-side JavaScript to server-side PHP using Ajax, and then retrieve the processed result back to JavaScript for further use. While I have managed to pass the data to PHP successfully, I am struggling to figure ...

Material-UI's style is taking precedence over other styles that have been defined

Introduction Last week, I posted a similar query which touched on the same issue. However, as the solution seems to be different this time around, I am revisiting it in a new thread. Check out the updated version of the CodeSanbox Example that reflects t ...

What is the best way to alter the order of the .map function in JavaScript to display in ascending or descending order?

I currently have 25 songs in my Spotify playlist, with the possibility of more being added in the future. The songs are numbered from 1 to 25. However, the map() function I use only displays the top 10 songs (1 to 10). When a new song is added, it is assig ...

Is it possible to run concurrent PostgreSQL queries in NodeJS?

I'm unsure why, but the task is supposed to be run in parallel and should only take 2 seconds: const test = async () => { client.query("SELECT pg_sleep(2) FROM test", (err, result) => { console.log("DONE!"); }) client.query("SELECT pg ...

Retrieve a file from an Express API using React with the help of Axios

When working with a React client and an Express API, how can the React client download a file sent by the Express API? Issue: If I manually enter the URL into my browser's address bar and hit enter, the file downloads successfully. However, when I ...

Issues with Braintree webhooks and CSRF protection causing malfunction

I have successfully set up recurring payments with Braintree and everything is functioning properly. Below is an example of my code: app.post("/create_customer", function (req, res) { var customerRequest = { firstName: req.body.first_name, lastN ...

The vertical tabs in JQueryUI lost their functionality when a few seemingly unrelated CSS styles were added

Check out the JsFiddle demo here I embarked on a mission to craft JQueryUI Vertical tabs by following the guidance provided in this example. The source code within the aforementioned link contains specific CSS styles: .ui-tabs-vertical { width: 55em; } ...

Using Javascript outside of the AngularJS environment

I am trying to utilize Javascript functions outside the controller in Angular JS instead of using a service within a module. Is this allowed? For instance: var UrlPath="http://www.w3schools.com//angular//customers.php" //this section will store all the f ...

Handling HTTP calls in Vue.js before the beforeunload event

I am facing an issue with the beforeunload event in my Vue.js application. I have a scenario where I need to make an HTTP call to check if the user is still logged in or if their session has expired on the backend. However, it seems that the event does no ...