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.

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

See original GitHub issue

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.

Issue Analytics

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

github_iconTop GitHub Comments

2reactions
simpleasnothingcommented, Oct 27, 2020

same issue

0reactions
balazsorban44commented, Jan 29, 2022

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Data Fetching: getStaticPaths
If fallback is false , then any paths not returned by getStaticPaths will result in a 404 page. When next build is run,...
Read more >
getStaticPaths() returns 404 Page Not Found
Seting it as false will return a 404 page because the requested path was not generated during build time. return{ paths, fallback: true...
Read more >
19 Blocking Fallback for getStaticPaths in Next.js - YouTube
Chapter Eighteen : How to Return 404 status code while using Fallback Blockingnext js custom 404 not working, next js 404 getserversideprops ...
Read more >
Next.js Tutorial - 26 - getStaticPaths fallback false - YouTube
Courses - https://learn.codevolution.dev/⚡️ Checkout Taskade! https://www.taskade.com/ Support UPI - https://support.codevolution.dev/  ...
Read more >
getStaticPaths is returning routes, but I keep getting a 404 ...
When I click on a post to go to /blog/{slug} , I get a 404 error that ... post.url}})); console.log(paths) return { paths,...
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