-
Notifications
You must be signed in to change notification settings - Fork 27.2k
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
Public files not accessible on i18n domains #54765
Comments
I haven't checked the reproduction but it seems to me similar to #54159 |
I'm encountering a the same issue 😞. I stumbled upon this GitHub issue after creating local "minimal" example. Since I'm using next-translate-routes in my project I thought it's caused by mentioned library. Instead, it seems to be a bug within Next.js itself. Have you tried alternative approaches to handle locale domain routing, perhaps using middleware or other methods? |
I don't want to jump to conclusions, but it seems to me that |
In another project we also have an issue in the latest version, going back to In that project client side routing didn't work anymore, since I haven't looked into what could have cause all these issues, but it seems something with routing is going on that breaks multiple things. |
I am facing similar problems with images in the public dir. Any solutions other than dropping the version to 13.4.12? |
I found the same bug on version 13.2.1 |
Having the same issue with the latest versions of next ( I managed to fix this for now by patching the next package with the solution of this PR diff --git a/node_modules/next/dist/server/lib/router-utils/filesystem.js b/node_modules/next/dist/server/lib/router-utils/filesystem.js
index 635fcdc..f56164e 100644
--- a/node_modules/next/dist/server/lib/router-utils/filesystem.js
+++ b/node_modules/next/dist/server/lib/router-utils/filesystem.js
@@ -348,7 +348,7 @@ async function setupFsCheck(opts) {
let locale;
let curItemPath = itemPath;
let curDecodedItemPath = decodedItemPath;
- const isDynamicOutput = type === "pageFile" || type === "appFile";
+ const isDynamicOutput = type === 'pageFile' || type === 'appFile' || type === 'publicFolder'
if (i18n) {
const localeResult = handleLocale(itemPath, // legacy behavior allows visiting static assets under
// default locale but no other locale
|
the current fix that i managed to do is that instead of having the const RobotsTxt = () => {}
export const getServerSideProps = async ({ res }) => {
// GENERATE ROBOT DATA
const robotsTxtData = `User-agent: *\nAllow: /`
res.setHeader("Content-Type", "text/plain")
res.write(robotsTxtData)
res.end()
return { props: {} }
}
export default RobotsTxt this way it work with any version of nextjs, localisation and also whenever you have a first level programatical route such as Now the fact that the whole My temporary solution was to create a subdomain with nginx to host all the assets and point the links from there. |
Having this problem as well! For example, https://www.iroomit.com/fonts/Crimson_Pro/CrimsonPro-Bold.woff2 is accessible, but https://www.iroomit.co.uk/fonts/Crimson_Pro/CrimsonPro-Bold.woff2 is not... |
Having the same issue. Public folder files are only accessible from the top-level defaultLocale (i18n.defaultLocale). |
I have the same issue in NextJS up to latest version ...
COPY --from=builder /app/public ./public
COPY --from=builder /app/public ./public/{locale} # <-- added this line
... |
We're using docker to deploy too and this works great as a workaround in the meantime. Thank you! |
Also having the same issue. We haven't been able to update from 13.3. This is a silly issue with a really small fix. I imagine a lot of people would have this problem?? Please, just fix it already! |
If it's a really small fix, why not fix it yourself and submit a pr? ;) |
I think there is a PR already to fix the solution but it was not approved and time passed. The docker solution works fine in a case that you handle translation within sub urls but if you handle multiple domains then it doesn't work as expected. The lesson learned here is to not rely on nextjs for assets in multi domain applications and handle it in a S3/gcloud/azure bucket that point to a different sub domain etc. |
|
@arielvieira |
@kamesdev - we also use the fix with v13.5.6 and it works really great. We added this line in our Dockerfile to "patch" nextjs: @arielvieira - thank you very much for this workaround!! |
What if I don't use docker? How can I do this without docker? |
Nice, i will tryout on our next release, this might work. @kamesdev If you don't use docker i assume you still have a release process for a versel/heroku something and that reference to a script within your application right? Generaly its associated to your package.json scripts just make sure to add a pre-install/pre-build step where you do |
@erwanrioualbelli Thanks for reply and solution. Will this work locally with "npm run dev"? |
@kamesdev You can also use patch-package |
I'm bumping this, as we are stuck to NextJS 13.4.12 😅 without this change |
It has become crucial for us too, as we are also stuck at version 13.4 🆘 |
IF THE FIX WAS TINY WHAT'S TAKING SO LONG?! 5 MONTHS NOW?! WTF GUYS!!! FIX THIS SHIT ALREADY!!! |
|
Such aggressive and disrespectful language is not constructive and doesn't help at all. Get it together dude. |
@timneutkens Hallo Tim, could the team take a look at the following #59773? This should solve the issue and even contains tests as requested in #55137. |
hello, today I encountered the same problem, I'm solving it by copying the public folder, please any update?
|
This closed issue has been automatically locked because it had no new activity for 2 weeks. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you. |
Verify canary release
Provide environment information
Operating System: Platform: darwin Arch: arm64 Version: Darwin Kernel Version 22.6.0: Wed Jul 5 22:22:05 PDT 2023; root:xnu-8796.141.3~6/RELEASE_ARM64_T6000 Binaries: Node: 20.2.0 npm: 9.6.4 Yarn: 1.22.19 pnpm: 8.7.0 Relevant Packages: next: 13.4.20-canary.12 eslint-config-next: 13.4.19 react: 18.2.0 react-dom: 18.2.0 typescript: 5.2.2 Next.js Config: output: N/A
Which area(s) of Next.js are affected? (leave empty if unsure)
Internationalization (i18n), Routing (next/router, next/navigation, next/link)
Link to the code that reproduces this issue or a replay of the bug
https://app.replay.io/recording/reproduction--e17b7c87-6019-40b2-b719-1e9b9ce80b13
To Reproduce
/robots.txt
/robots.txt
Describe the Bug
This bug presented itself specifically in Next v13.
Public files are no longer accessible on all domains that are not the default domain (default locale domain).
Expected Behavior
All files in public folder should be accessible on every domain that is setup in the i18n config.
Which browser are you using? (if relevant)
No response
How are you deploying your application? (if relevant)
No response
The text was updated successfully, but these errors were encountered: