Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

router.back() not working when going back between two dynamic routes #25285

Closed
Assignees
ijjk
@DaniAkash

Description

@DaniAkash

What version of Next.js are you using?

10.2.2

What version of Node.js are you using?

14.15

What browser are you using?

Chrome

What operating system are you using?

macOS

How are you deploying your application?

vercel

Describe the Bug

I have a dynamic route in the following format:

/path/[type]

If i visit the following paths:
/path/custom1
/path/custom2

and then call router.back() from custom2 I get the following error message:

Unhandled Runtime ErrorError: The provided `as` value (/path/custom1) is incompatible with the `href` value (/h/[type]). Read more: https://nextjs.org/docs/messages/incompatible-href-asCall StackRouter._callee$node_modules/next/dist/next-server/lib/router/router.js (1055:16)tryCatchnode_modules/regenerator-runtime/runtime.js (63:14)Generator.invoke [as _invoke]node_modules/regenerator-runtime/runtime.js (293:0)Generator.eval [as next]node_modules/regenerator-runtime/runtime.js (118:0)asyncGeneratorStepnode_modules/@babel/runtime/helpers/asyncToGenerator.js (3:0)_nextnode_modules/@babel/runtime/helpers/asyncToGenerator.js (25:0)

I use my app with a basepath. It is happening only when I have a basepath. My next.config.js file is:

module.exports={basePath:"/app",future:{webpack5:true}};

Given my application has lots of dynamic routes I'm unable to upgrade from 10.0 to 10.2.

Expected Behavior

The page should be able to go back from /path/custom2 to /path/custom1

To Reproduce

I have created a codesandbox with reproducable scenario:

https://znkfe.sse.codesandbox.io/app

If the buttons are followed, it will land on the issue.

Source:https://codesandbox.io/s/nextjs-routing-issue-znkfe?file=/pages/index.js

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions


    [8]ページ先頭

    ©2009-2025 Movatter.jp