Next-translate: Custom 404 page with defaultLangRedirect configuration

Created on 25 May 2020  Β·  7Comments  Β·  Source: vinissimus/next-translate

Hi Teams,
I'd like to use defaultLangRedirect configuration but I'm facing on the issue that cannot use own custom 404page with this configuration.

By-right 404.js is located under pages folder, but this file will be generated in each language folder.
In my case, 404.js generated in both /pages/en and /pages/zh. But 404.js should be generated at pages folder.

Kindly please help to advise how to solve this issue.
Thank you.

Repo: https://github.com/roy1210/next-ts-boiler-code

bug

All 7 comments

Hi @roy1210, I added this as a bug in order to fix this asap. The behavior should be same as _error.js page. Thanks to report it!

@roy1210 I released 0.16.1 today with this fixed. It should work now! Thanks 😊

Hi @aralroca

Thank you for fixing!
Unfortunetely, custom 404page still not working correctly with "defaultLangRedirect": "lang-path", configration.
(404 page will works either remove defaultLangRedirect or change to "defaultLangRedirect": "root",, but I want to use language path even default language. TT Orz)

It seems weird, 404.jsx has generated under pages folder, but it not work correctly and the browser shows default 404| This page could not be found when open not-existing path.

Is this behavior because related to some redirect issue ?? (since /en/ is added into URL address when open error page...)

This is the gif I took for with defaultLangRedirect": "lang-path", and without "defaultLangRedirect": "lang-path", . Please take a look.

=With defaultLangRedirect": "lang-path",=
https://gyazo.com/1424a9ce7f1897bceff62d53581732f9
γ‚Ήγ‚―γƒͺγƒΌγƒ³γ‚·γƒ§γƒƒγƒˆ 2020-05-26 εˆε‰8 05 08

=Without (removed) defaultLangRedirect": "lang-path",=
https://gyazo.com/b85f287838278b92e11014969528d64f
γ‚Ήγ‚―γƒͺγƒΌγƒ³γ‚·γƒ§γƒƒγƒˆ 2020-05-26 εˆε‰8 21 47

Repo: https://github.com/roy1210/next-ts-boiler-code

Ok, I understand. It's for the redirect, yes... because the CatchAll have the import Error from 'next/error'. I reopen the issue πŸ‘

Hi @aralroca ,

Thank you for reopen this issue.
Kindly please advise when will you have a time to fix this issue :D
I'll install latest version once it fixed!

@roy1210 I did a prerelease 0.17.0-canary.2 with this change, it should work now 😊

Thanks for that amazing feedback, it was very useful!

Hi @aralroca

Yes, I think the problem has solved with 0.17.0-canary.2 ! Thank you so much!!!!

I think there is 1 point that can be improved but this might be not easy.
When the user typed wrong URL path, the page will redirect to default language path. But this effect will brings rendering HTML element twise.
It will be awesome if do not redirect to language path when showing 404 page.
Ref: https://gyazo.com/39ba8647f3c079fce27ec9bba700dacc

I guess no need to re-open if above request is impossible to make it. Anyway, thank you so much!

Was this page helpful?
0 / 5 - 0 ratings