-
Notifications
You must be signed in to change notification settings - Fork 26.7k
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
How to change default _next in request path into something custom #5602
Comments
There is no need for doing this. So it's not possible to change the path. |
There is a need : Android build does not get folder starting with an undescore. |
@timneutkens I am wondering about this too, I am looking at running 2 nextjs apps on the same domain as subroutes. Here is an example of my routing configuration:
Without being about to change the |
I have a situation similar to @zlwaterfield . |
There is a need as hackers / attackers will be able to guess a website is using next.js just from seeing the _next. Please revisit this issue @timneutkens |
Again this is not an issue, it's super easy to detect any framework in existence. You could detect next based on There is no way for us to cover these cases, and even if we did it's easy to detect based on file contents. So this is not a security issue. |
@timneutkens I'm not concerning about security issue. I just encountering the same requirement like @zlwaterfield . We will have multiple nextjs app in different server at the same time, and we will use a reverse proxy server to forward our request to different server according to our url. Our application like: we need these app1urlpattern and app2urlpattern to be different. |
|
hi @timneutkens, Does |
@ferrybrouwer I found the solution here @timneutkens WDYT? |
I handled this issue via Nginx Routing. What i assumed while making this Nginx Routing is that every file will have unique hash and file name combination. This is the snippet of code of Nginx Routing which i used.
What the above code does is, whenever Nginx encounters /_next/ it will first try that URL with @server1, if that Server responds with 404, the Nginx then transfers the request to @server2 as mentioned in error_page param. This example works like: This worked for me as i had 2 apps which were developed on Next and both has _next route. Let me know if this solves your problem. |
We have the same situation of wanting to run multiple Next apps on the same domain. In our production and production-like envs we use a CDN, and so the However in other envs we don't use a CDN (e.g. local development env), but still want to sometimes run multiple Next apps on the same domain. The We don't want to use the Next Having a configuration option that allows the |
Using Next.js 9.5 something like this should cover your case just fine: module.exports = {
assetPrefix: '/docs',
rewrites() {
return [
{ source: '/docs/_next/:path*', destination: '/_next/:path*' }
]
}
} |
Thanks @timneutkens!! |
I am facing the same issue, have you got any solution for this? |
@timneutkens This works for everything except for |
I was curious if there had been any activity on this, and I see the issue is still unresolved and closed. I did a hack to get a next.js chrome extension working a while ago & ran into this issue. I was wondering if anyone else had run across the same issue and found this nice blog post: https://alexbh.dev/posts/2021-01-27-next-js-extension It's exactly what I did! It would be nice if aspiring browser extension developers didn't have to. |
@timneutkens the |
@okayrunner @timneutkens the same here! I have two next app using a domain, mydomain.com/home and mydomain.com/feed, when I open home page it's ok, but when I open feed page, it return the _next folder from home app, mydomain.com/_feed! Work over subfolder "path" or subdomain is not a good solution because I can to have many apps / micro frontends! |
@okayrunner the same issue. We have a next app that is mounted on a specific path, let say |
I was using this on Next 9.5.3 and it worked fine. In Next 11 it no longer works. |
@timneutkens aligning asset paths with non-next frameworks is not possible, for instance so that CDN path rules can easily be configured across frameworks, without this feature. there is absolutely a need for this feature. |
This doesn't cover the case for requests to _next/data 😢 is the change of _next to something a technical limit in nextjs and vercel? 🤔 I think this can be considered as a 'Feature request' |
Seems lots of people need this feature - having the ability to provide custom name (or prefix) instead of |
Thank u so much |
I face the same issue when use nextjs v10. Does anyone have any workaround for it |
For Nextjs 11+ I've find it working to do this: on module.exports = {
assetPrefix: '/myprefix',
} on import { NextRequest, NextResponse } from 'next/server';
export function middleware(req: NextRequest): NextResponse {
if (req.nextUrl.href.includes('/myprefix/_next/'))
return NextResponse.rewrite(
req.nextUrl.href.replace('/myprefix/_next/', '/_next/'),
);
return null;
} |
Thank you @Negan1911 - you save me :)
|
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. |
Question about Next.js
Questions should be posted on https://spectrum.chat/next-js
I use next@7. And after build, I run a custom server follow the document, then I see my .js file was requested by route like http://localhost:3000/_next/static/runtime/webpack-89179faa512dd01fbb62.js, any chance to change _next into something customized path ?
Thanks
The text was updated successfully, but these errors were encountered: