Creating a personalized router with Nuxt

Currently, I am working on setting up a custom route in Nuxt using the following nuxt.config.js:

router: {
    base: '/',
    router: {
      extendRoutes (routes, resolve) {
        routes.push({
          name: 'custom',
          path: 'here-i-am',
          component: resolve(__dirname, 'pages/Slug.vue')
        })
      }
    }
  },

However, when trying to access localhost:3000/here-i-am, it is displaying an error message: This page cannot be found. I have already created Slug.vue in the /pages directory.

Could there be something else missing? I even attempted to recompile but with no success.

Answer №1

Here are a couple of issues to address:

  1. Ensure that the extendRoutes function is placed at the top level of the router property instead of being nested within another router property.
router: {
  extendRoutes() {...}
}
  1. Remember to begin the path property with a leading slash for non-nested routes:
routes.push({
  path: '/here-i-am'
})

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

Adjusting the bottom property to a negative value in CSS will stretch the page downwards

I want to hide a portion of an HTML element at the bottom of the page and then reveal the entire element by sliding it upwards upon clicking with the help of CSS3 transitions. The expected behavior is for the part of the element extending below the page t ...

Setting up a universal property for all components across an application

I'm currently working on a Vue.js component, however, I lack experience and I am unsure about how to implement the concept I have in mind. The concept involves creating a reusable component with a string URL property that will be applicable to all ins ...

Mastering the art of utilizing $filter alongside select in angular.js

Is there a way to switch between different filters based on the user's selected values? I have three filters ('largeNumber', 'Percentage', 'Bytes') and I want to toggle between these filters based on the selection made by ...

Encountered issues while trying to utilize wasm function within Vue framework

When attempting to integrate wasm with Vue, I encountered a frustrating issue where the startQuorum function in my wasm file could not be located. import { Go } from './wasm_exec' import quorumWasmUrl from './lib.wasm' export const sta ...

The development mode of NextJS is experiencing issues, however, the build and start commands are functioning normally

Just finished creating a brand new Next app (version: 12.0.7) using Typescript and Storybook. Everything seems to be working fine - I can successfully build and start the server. However, when I try to run dev mode and make a request, I encounter the follo ...

Node.Js made user authentication effortless

Struggling to integrate user authentication using Passport, Express, and Node.Js as tutorials mostly focus on MongoDB. However, I prefer Neo4J for my database. The examples on passport-local don't fit my needs since I've already implemented a loc ...

Using data from an API, I am implementing JavaScript validation for my dropdown select menu

Using an API, I am able to access information about the city's subway stations through a select option. Currently, I can only display details about one station (Balard). However, I would like to be able to display information about other stations tha ...

What is causing the check box in the simple_form view to consistently return a value of 1 when checked or unchecked in rails 3.2?

A checkbox with the name "need_delivery" is used to determine whether the next two text boxes should be displayed. These two text boxes are enclosed within a div with the id of task_request_delivery. Below is the code snippet in the simple_form view named ...

When using angular-ui-select and having an empty <option>, it displays two blank fields

I have implemented angular-ui-select for dropdowns and I want to include a cancel feature in the dropdown. This is the dropdown structure in my template: <select ui-select2="select2Options" name="Machine" ng-model="selectedMachine.type" data-placehold ...

Step-by-step guide to creating a polyline on OpenStreetMap using JavaScript arrays

I am looking to create a polyline on OpenStreetMap using a marker array object. Currently, I am retrieving all marker (longitude, latitude) values from the database and based on those markers, I want to draw a polyline to display the route of a specific ...

Creating a scheduled redirect button using JavaScript and another button to cancel it

I'm facing an issue with my code. When the first button is clicked, it redirects the user to a different URL after 10 seconds. However, I'm struggling to make the second button cancel the redirect if pressed before the 10 seconds are up. Despite ...

AngularJS - Custom directive to extract a property value from an object

Currently, I am using the following for loop to retrieve the parent category: angular.forEach(queryTicketCategories, function(category) { if(category.id === $scope.ticketCategory.parentId) { $scope.parent = category; } }); I am looking fo ...

Guide to loading an image and incorporating it into a canvas using Gatsby's server-side rendering

I encountered an issue where I was unable to create an image using any of the supported types like CSSImageValue, HTMLImageElement, SVGImageElement, HTMLVideoElement, HTMLCanvasElement, ImageBitmap, or OffscreenCanvas in my SSR application with Gatsby. De ...

Ways to verify the existence of a particular word within a nested array of objects

I have implemented a text input field and a send button for submitting the entered text. Utilizing the react-mention library, I am able to handle hashtags in the text. As the user types, if they include "#" it displays available hashtags from the data set. ...

Guide to utilizing JSDoc within your local project

Objective My goal is to utilize jsdocs with npm in my project. Experience I am new to working with npm and its plugins. Recently, I came across jsdoc and attempted to incorporate it into my project without success. Attempted Solution Initially, I inst ...

Using AngularJS to access JSON files through the $http service

I'm experiencing difficulties reading data from my test.json file using the #http service. I have everything set up on a xampp localhost, but I can't seem to figure out what's going wrong. Here's the JavaScript code. Thank you in advanc ...

How can we toggle a function to expand or collapse fields generated in an ngFor loop?

One of my challenges involves managing a div that is repeated using *ngFor in Angular. This results in multiple divs on the page, each containing collapsible fields that can toggle. Essentially, I have nested collapsible fields within other collapsible fie ...

Using a JavaScript variable within an AngularJS scope

Currently in the process of building a webpage with the MEAN stack, I utilized the HTML5/Javascript sessionStorage variable to store the user data for access across all pages. Now, the challenge is passing this data into angularJS through the controller w ...

Retrieve the HTML code from a webpage on a different domain

Looking to extract HTML from another domain. Attempted solution: $.get("http://website1.com", function(data) { alert("Data Loaded: " + data); }); (not working) For example, as the owner of two websites: website1.com website2.com Now, the goal is to ret ...

Transmit information from a bean to JavaScript using JSON in JavaServer Faces

I need help transferring my arraylist from a managedBean to JavaScript code. The bean code is shown below: public void getDataAsJson(){ String [] dizi={"Tokyo","Jakarta","New York","Seoul", "Manila","Mumbai","Sao Paulo","Mexico City", ...