Utilizing the exportPathMap method in your next.config.js file to configure dynamic routes within NextJS

I'm currently facing an issue with setting dynamic routes using Exportpathmap() in nex.config.js. The static routes are working as expected, but when I attempt to apply dynamic routing, the URL redirects me back to the main URL.

If anyone has a solution for this problem, please help me out. Thanks in advance!

Below is my next.config.js:

return {
    reactStrictMode: true,
    env: env,
    trailingSlash : true,
    eslint: {
        ignoreDuringBuilds: true,
    },
    swcMinify: true,
    images: {
        domains: ['cdn.pixabay.com', 'pixabay.com', 'cdn.landrrapp.io'],
        loader: 'akamai',
        path: '',
    },
    exportPathMap: async function (
        defaultPathMap,
        { dev, dir, outDir, distDir, buildId }
      ) {
        return {
          '/404': { page: '/404' },
          '/forgot-password': { page: '/forgot-password' },
          '/login': { page: '/login' },
          '/editor/[id]': { page: '/editor/[id]' },
        }
      },
}

The specific issue seems to be related to this line: '/editor/[id]': { page: '/editor/[id]' },

NEXT JS: Build exportPathMap for a dynamic page Route The link above looks promising, but I'm having trouble understanding the line "

import { PAGE_ROUTES } from '../constants/config';
" in that file.

Answer №1

You can implement this

    '/editor/Another Page': { page: '/editor/[id]' },
    '/editor/Another Page 2': { page: '/editor/[id]' },
    .
    .
    .

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

What is the best way to add controllers to AngularJS?

What is the best way to troubleshoot this setup? app.js var app = angular.module('app', ['ui.router', 'app.controllers']); /* Why is FooCtrl not being recognized here? */ controllers.js var controllers = angular.module(&a ...

the event listener for xmlhttprequest on load is not functioning as expected

I am facing an issue with validating a form using JavaScript and XMLHttpRequest. The onload function is supposed to display an alert, but it only works sometimes. I'm struggling to identify my mistake. document.getElementById("button").addEventListen ...

Navigating through various features in nodejs / expressjs

Managing multiple functions in nodejs/expressjs can be a bit confusing for those used to PHP. In PHP, you simply call one function after another, but in node, things work differently with callbacks and potential errors related to undefined variables. Her ...

Unlimited scrolling with React and Meteor

Struggling with implementing infinite scrolling in my Meteor and React app. Even after trying multiple npm and Meteor packages, I still can't get it to work. The "createContainer" function subscribes to the entire dataset of "links", but I only want t ...

A Complication Arises with Browser Functionality When Embedding an Iframe within

I am experiencing a peculiar problem while embedding an iframe with a specific src inside an absolutely positioned div. Here's the basic structure of the webpage: .container { position: relative; overflow: hidden; width: 100%; heigh ...

How can you prevent JQuery AJAX from automatically redirecting after a successful form submission?

Encountered an issue with loading http://example.com/signup.ashx: The redirect from 'http://example.com/signup.ashx' to '' was blocked by the CORS policy. This is due to the absence of 'Access-Control-Allow-Origin' header on t ...

Implementing a sticky second Navbar with Bootstrap 5 and Vanilla JavaScript to stay fixed at the top during scrolling

I am currently working on a project that involves two navbars. The first navbar is dedicated to contact information, while the second navbar contains menu links. My goal is to have the second navbar fixed at the top of the page when scrolling, and I am lo ...

Make sure to confirm the input length and utilize bootstrap validation for error checking

I have a rather straightforward question. I am currently utilizing Bootstrap 4.6 and am looking to implement form validation for my input field. The requirement is to validate whether the input has a length of 5 characters or less, in which case it should ...

The functionality of the browser's back button is impaired when the window.location.href is modified

My application used to be written in jQuery and was not SPA. I have recently converted some of the pages to AngularJS, making them SPA. Now, I am faced with the challenge of ensuring proper communication between these two types of apps. When transitioning ...

Error message: The variable "self" is not defined when using React-Pixi and Next-urql libraries

I am encountering an issue while using Next-Urql and React-Pixi. It seems that React-Pixi requires WEB APIs, leading to this error: Server Error ReferenceError: self is not defined This error occurred during page generation. Any console logs will be shown ...

What could be causing my react-lightbox to not expand to full screen in next.js?

I'm facing an issue in my next.js project where I am unable to view my gallery collection as expected. When clicking on an image, nothing happens as if it's just a regular component being used. Can someone please assist me with this problem? / ...

What is the most efficient method for dynamically defining values in react-hook-form within a next.ts application?

In my current project using next.ts, I am faced with the task of dynamically setting the fields of a form created with react-hook-form. To assign the "name" parameter as a literal string, I have been utilizing the as operator like this: type val = "busines ...

Is it possible to Use Vuejs 2 to Update MathJax dynamically?

Just figured out how to resolve this issue. Simply bind the data using v-html <div id="app"> <h1 v-html="equation"></h1> <button @click='change'>Change</button> </div> var vm ...

A div element springs forth into a new window and seamlessly transitions back to its original position with fresh content

Most of us are familiar with Gmail chat, where you can pop out the chat window into a new window with its content, and then pop it back in to its original position. However, I encountered an issue while working on replicating this functionality. While I w ...

Refresh Angular controller after ng-click event is triggered

In my current setup, I have a controller that consists of one main object containing various functions. Initially, default values for variables are set and the init() function is used to fetch data from the database. Everything on the page seems to be fu ...

Embedding Google+ Sharing in an iframe

I'm currently working on a web application that needs to be compatible with PC, tablets, and mobile phones. I'm interested in integrating Google+ Sharing into the app. However, it appears that when using the url , there are issues with blocking ...

Boost your website's performance by optimizing the display of 80,000 markers on Google Maps

How can I optimize the loading speed of a Google map with 80,000 markers using the functions setMarkers() and createMarker()? The page is currently taking a long time to load. Here is the code snippet: function initialize() { //markers details are c ...

Using a URL in an AJAX request

Before redirecting to another page, I am storing data from a textbox. When the user clicks the back button on the page load function in JavaScript, I retrieve the data from the textbox using: var pageval = $('#grid') .load('/Dealer/AllClai ...

Hunt for text embed features

Is there a way to configure the embed tag so that when I press Ctrl + F, it only searches within the displayed PDF file and not the entire current page? I've tried searching on Google but haven't found a solution yet. ...

Searching for a point within a specified range using Sequelize

I have a model called Location with a field named coordinates of type geometry. I'm looking to create a function that takes in latitude, longitude, and radius as parameters, and returns all locations within that radius (in meters). I attempted to foll ...