Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Non-consistent basePath checking behaviour #38984

Closed
1 task done
eolme opened this issue Jul 25, 2022 · 5 comments
Closed
1 task done

Non-consistent basePath checking behaviour #38984

eolme opened this issue Jul 25, 2022 · 5 comments
Labels
bug Issue was opened via the bug report template.

Comments

@eolme
Copy link
Contributor

eolme commented Jul 25, 2022

Verify canary release

  • I verified that the issue exists in the latest Next.js canary release

Provide environment information

    Operating System:
      Platform: darwin
      Arch: arm64
      Version: Darwin Kernel Version 21.5.0: Tue Apr 26 21:08:37 PDT 2022; root:xnu-8020.121.3~4/RELEASE_ARM64_T6000
    Binaries:
      Node: 16.15.0
      npm: 8.5.5
      Yarn: 3.2.1
      pnpm: N/A
    Relevant packages:
      next: 12.2.3
      eslint-config-next: N/A
      react: 18.2.0
      react-dom: 18.2.0

What browser are you using? (if relevant)

No response

How are you deploying your application? (if relevant)

No response

Describe the Bug

If basePath is an empty string, a warning is displayed:

warn  - Invalid next.config.js options detected: 
[
  {
    "instancePath": "/basePath",
    "schemaPath": "#/properties/basePath/minLength",
    "keyword": "minLength",
    "params": {
      "limit": 1
    },
    "message": "must NOT have fewer than 1 characters"
  }
] 
See more info here: https://nextjs.org/docs/messages/invalid-next-config

But if you set the basePath to / an error occurs:

Error: Specified basePath /. basePath has to be either an empty string or a path prefix"
    at assignDefaults (/node_modules/next/dist/server/config.js:266:19)
    at Object.loadConfig [as default] (/node_modules/next/dist/server/config.js:97:16)
    at async NextServer.prepare (/node_modules/next/dist/server/next.js:115:24)
    at async /node_modules/next/dist/cli/next-dev.js:147:9

Expected Behavior

Allow either an empty string or a slash as basePath

Link to reproduction

To Reproduce

@eolme eolme added the bug Issue was opened via the bug report template. label Jul 25, 2022
@rikers
Copy link

rikers commented Jul 25, 2022

probably related to issue #38967

@ijjk
Copy link
Member

ijjk commented Jul 25, 2022

Hi, an empty string isn't a valid basePath and was previously normalized automatically since it's a falsy value so this warning is valid and the basePath value should be omitted for this case.

@ijjk ijjk closed this as completed Jul 25, 2022
@eolme
Copy link
Contributor Author

eolme commented Jul 25, 2022

@ijjk but the error explicitly says that there may be an empty string 😕

@ijjk
Copy link
Member

ijjk commented Jul 25, 2022

Hmm since we do mention the empty string is allowed and we normalize the value, it seems alright to avoid the warning here

@github-actions
Copy link
Contributor

This closed issue has been automatically locked because it had no new activity for a month. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 25, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue was opened via the bug report template.
Projects
None yet
Development

No branches or pull requests

3 participants