Getting 404 when using localeSubpaths and next-route for dynamic routing
See original GitHub issueHi, I am not sure if it is my setup issue or the 2 packages are conflicting…
I have a product.js
under pages/
directory
I am support 2 languages with these pattern
/product/1
/zh/product/1
However, only the default route (en) works This is my setup
routes.js
const routes = require('next-routes');
module.exports = routes()
.add({
name: 'product',
pattern: '/(zh)?/product/:id',
page: 'product',
});
i18n.js
const NextI18Next = require('next-i18next');
module.exports = new NextI18Next({
otherLanguages: ['zh'],
defaultLanguage: 'en',
localeSubpaths: true,
});
server.js
const express = require('express');
const next = require('next');
const nextI18NextMiddleware = require('next-i18next/middleware');
const nextI18next = require('./i18n');
const routes = require('./routes');
const app = next({ dev: process.env.NODE_ENV !== 'production' });
const handler = routes.getRequestHandler(app);
const server = express();
app.prepare()
.then(() => {
nextI18NextMiddleware(nextI18next, app, server);
server
.use(handler)
.listen(3000, (err) => {
if (err) {
// eslint-disable-next-line no-console
console.error('err', err);
}
});
});
I have read the documentation of both pacakges and tried lots of combination for routes.js
, but still can’t make it work.
Am I doing this correctly?
Issue Analytics
- State:
- Created 5 years ago
- Reactions:3
- Comments:12 (7 by maintainers)
Top Results From Across the Web
Getting 404 when using localeSubpaths and next-route for ...
Hi, I am not sure if it is my setup issue or the 2 packages are conflicting.. I have a product.js under pages/...
Read more >Getting 404 when first loading dynamic routes on nextjs
The real issue is that exporting a next app will make it generate static HTML files. Even though it will still be able...
Read more >How to return a 404 Not Found page for dynamic routes in ...
For getStaticProps the page will return a 404 even if there was a successfully generated page before. This is meant to support use-cases...
Read more >Dynamic Routes Details - Next.js
Here is some essential information you should know about dynamic routes. ... then any paths not returned by getStaticPaths will result in a...
Read more >Eror:404 using Page template for Custom Home Page - Routing
When I'm trying to use default page.hbs as template and create a home page using content from vamsithota.me/home, I'm getting a 404 error....
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I passed
next-routes
request handler function intonext-i18next
middleware and I think it works.Closing due to lack of activity, happy to reopen this at any time. I would imagine that @wk93’s approach probably works.