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

getStaticPaths with fallback: false, return 404 page for non-ASCII/non-Latin url #17642

Closed
kittipongint opened this issue Oct 6, 2020 · 5 comments · Fixed by #19135
Closed
Assignees
Milestone

Comments

@kittipongint
Copy link

Bug report

Describe the bug

In the following page called pages/a/[slug]/index.js

export async function getStaticPaths() {
  return {
    paths: [{ params: { slug: 'Synonyms' } }, { params: { slug: 'อักษรย่อ' } }],
    fallback: false,
  };
}

export async function getStaticProps({ params }) {
  const res = await fetch(getApplicationDetailBySlug(params.slug));
  const app = await res.json();

  return {
    props: { app },
  };
}

The value of slug is dynamic value that can be ASCII or Non-ASCII characters, So, When navigate to url of ASCII (Synonyms), Page rendered correctly but for Non-ASCII (อักษรย่อ), I got 404 page.

List of urls:

  • อักษรย่อ
    Url: /a/อักษรย่อ
    encodeURIComponent: /a/%E0%B8%AD%E0%B8%B1%E0%B8%81%E0%B8%A9%E0%B8%A3%E0%B8%A2%E0%B9%88%E0%B8%AD

  • Synonyms
    Url: /a/Synonyms
    encodeURIComponent: /a/Synonyms

To Reproduce

Steps to reproduce the behavior, please provide code snippets or a repository:

  1. in getStaticPaths(), Use url param with non-ascii characters, I think for all non-latin language will face this issue, e.g. Thai, Chinese, Japanese.
  2. fallback: false
  3. browse the url in browser.
  4. See 404 error page.

Expected behavior

Should return correctly of url path and param for all encoding in fallback: false mode.

Screenshots

Page of non-ascii url:
image

Page of ascii url:
image

Result from build command
image

Files from build command in .next folder:
image

System information

  • OS: Windows 10 Pro (WSL Bash shell)
  • Version of Next.js: 9.5.3
  • Version of Node.js: v12.18.4

Additional context

OSX is got same behavior and 404 page. So, Path syntax is not root cause for this case for sure.

@simpleasnothing
Copy link

same issue

@foooomio
Copy link

Maybe same as #10084

@fillon

This comment has been minimized.

@kodiakhq kodiakhq bot closed this as completed in #19135 Dec 28, 2020
kodiakhq bot pushed a commit that referenced this issue Dec 28, 2020
…19135)

This ensures we handle encoding/decoding for SSG prerendered/fallback pages correctly. Since we only encode path delimiters when outputting to the disk we need to match this encoding when building the `ssgCacheKey` to look-up the prerendered pages. This also fixes non-ascii prerendered paths (e.g. 商業日語) not matching correctly. 

This does not resolve 👉  #10084 and further investigation will be needed before addressing non-ascii paths for non-SSG pages. 

The encoding output was tested against https://tst-encoding-l7amu5b9c.vercel.app/ to ensure the values will match correctly on Vercel. 

Closes: #17582
Closes: #17642
x-ref: #14717
@ijjk
Copy link
Member

ijjk commented Dec 28, 2020

Hi, this has been updated in v10.0.5-canary.1 of Next.js, please upgrade and give it a try!

@balazsorban44
Copy link
Member

This issue has been automatically locked due to no recent activity. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

@vercel vercel locked as resolved and limited conversation to collaborators Jan 29, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants