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.

change default _next in request path into something custom

See original GitHub issue

What version of Next.js are you using?

12.0.4

What version of Node.js are you using?

12.22.7 / 14.17.5

What browser are you using?

Chrome

What operating system are you using?

macOS

How are you deploying your application?

Local & Docker container

Describe the Bug

The following no longer works in Next.js 12 in combination with i18n Requests for static assets return a 404.

module.exports = {
  assetPrefix: '/docs',
  rewrites() {
    return [
      { source: '/docs/_next/:path*', destination: '/_next/:path*' }
    ]
  }
}

_Originally posted by @timneutkens in https://github.com/vercel/next.js/issues/5602#issuecomment-673382891_

Expected Behavior

changes default _next in request path into something custom

To Reproduce

$ yarn create next-app --typescript

next.config.js

/** @type {import('next').NextConfig} */
module.exports = {
  reactStrictMode: true,
  i18n: {
    locales: ['nl', 'de'],
    defaultLocale: 'nl'
  },
  assetPrefix: '/docs',
  rewrites() {
    return [
      { source: '/docs/_next/:path*', destination: '/_next/:path*' }
    ]
  }
}

$ yarn build $ yarn start

Go to http://localhost:3000/, static assets are not loaded

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:9
  • Comments:9 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
nmaddp1995commented, Dec 5, 2021

Do you have any workaround for that

0reactions
teemuycommented, Dec 15, 2022
Read more comments on GitHub >

github_iconTop Results From Across the Web

How to change default _next in request path into something ...
I use next@7. And after build, I run a custom server follow the document, then I see my .js file was requested by...
Read more >
Setting a custom build directory - next.config.js
Set a custom build directory to use instead of the default .next directory.
Read more >
Change a default URL to a custom path | Marketing Department
Change a default URL to a custom path · Click the URL path settings · Uncheck Generate automatic URL alias · In the...
Read more >
Change url to default page next.js - Stack Overflow
I have a structure in the pages directory in the form index/index.jsx and I want this page to be returned by default when...
Read more >
Routing - Laravel - The PHP Framework For Web Artisans
use App\Http\Controllers\UserController;. Route::get('/user', [ ...
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