question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

When using rewrites, client asPath is sliced by the basePath's length even when basePath config is false

See original GitHub issue

Bug report

Describe the bug

We’re trying to implement basePath in our repo and it works until we want to exclude any paths using rewrites in our config. When using rewrites we find that asPath is shortened by the basePath’s length even though we’ve set basePath to false. It appears that asPath works correctly on server, but not on the client.

To Reproduce

Using the following config, visit /diets and see asPath is “ts” instead of the expected “/diets”. Tried with both /web/diets and /diets as destination, both produce the same problem.

// next.config.js

basePath: '/web',
rewrites: () => [
  {
    source: '/diets',
    destination: '/diets',
    basePath: false,
  }]

Expected behavior

I expect the asPath to be “/diets”

See this file:

Line 41: packages/next/next-server/lib/router/router.ts <-- method that’s slicing asPath Line 64: packages/next/client/index.js <-- client does not check the config for basePath before slicing asPath

Screenshots

image

System information

  • Version of Next.js: 9.5.0
  • Version of Node.js: 12.16.0

Additional context

Add any other context about the problem here.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
sallomendocommented, Aug 3, 2020

I can confirm that the issue has been resolved, thanks!

1reaction
Timercommented, Aug 3, 2020

Please try out next@^9.5.2-canary.2 with the fix!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Rewrites - next.config.js
rewrites is an async function that expects to return either an array or an object of arrays (see below) holding objects with source...
Read more >
How to redirect / into basePath in Next.js config?
The problem is this rewrites and redirects are working with basePath only. For example async redirects() { return [ { source: '/test' ...
Read more >
Solidity Documentation
Solidity is statically typed, supports inheritance, libraries and complex user-defined types among other features. With Solidity you can create ...
Read more >
p4vnotes.txt
Release Notes for Helix Visual Client (P4V) Version 2021.4.2 Introduction Helix ... When this property is set, only URLs with bases that match...
Read more >
Product Manual
TNSR can scale packet processing from 1 to 10 to 100 Gbps, even 1 ... Configure TNSR to act as a DNS server...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found