The domain troubleshooting guide can help with most custom domain configuration issues. You might be able to use that guide to solve it before a human is available to help you. Then you can come back here and share the answer for bonus points.
You can also use v0 to narrow down the possibilities.
It seems like the vercel.json file has rewrites configured instead of redirects.
The following vercel.json will redirect all paths from https://markdown-syntax-hub.tcblabber.cn/ to https://tcblabber.cn/markdown-syntax-hub. Can you add it to the project using the subdomain?
I added the code snippet redirects above to vercel.json. It redirects the URL to the subpath designated in destination, but causes a 404: Not_Found error.
Hi @docsimpo, thanks for sharing your outcome. I just tried it myself for one of my projects and the redirect worked fine. The only difference is the trailingSlash in the config. Are you using specifically for some reason? If not can you try removing it?
Hi @docsimpo, I think there is a confusion here. It seems like you are expecting the behavior of rewrites from redirects. Can you help me answer these questions?
If you want to show the content of the http://markdown-syntax-hub.tcblabber.cn/ application on the subpath without a redirect. Then you need to use rewrites from Next.js
It is to be noted that the resources from the https://markdown-syntax-hub.tcblabber.cn app might fail to load if they are using the relative paths instead of absolute. To avoid this you can ensure that they use absolute path.
Hi @docsimpo, I was able to create an example of this. Where I rewrite the /blog route of my Next.js application to my blog application theanshuman.dev. I added the beforeFiles section to ensure the styles and js files load properly in the rewrite.
I added a vercel.json at the root directory of the main site (www.tcblabber.cn). The code in the vercel.json is an imitation of the external rewrites example:
markdown-syntax-hub/:1 GET https://www.tcblabber.cn/markdown-syntax-hub/ 404 (Not Found)
Navigated to https://www.tcblabber.cn/markdown-syntax-hub/
I like to know why prior to getting it work. If it can be fixed with a little effort, I like to go. Otherwise, I may leave it as it is until it can be done as simply as what the docs said.
I know nothing about Next.js. I can only copy and paste Next.js code. I am not a developer. If I need to learn Next.js, even though a little basics, I can feel a great pressure.
Hi @docsimpo, yes the rewrites are supposed to be minimal efforts. It’s just that in your case we’ve some other logic interfering. I just tried to recreate my example for your app and yes I also get a 404. Upon digging further I see some redirects that are causing the issue. I’ll keep you posted.
Hi @docsimpo, I tried to fix the redirect issue and I was able to get it working (https://latest-next-ten.vercel.app/my-blog/basic/emphasis) for a few pages. But, overall I think this will take a bit more effort because you will have to ensure the static assets load as well as the links on the blog are always relative so interlinking between the pages work.
I’m still not sure about the root cause for redirect, my guess is that it’s due to trailingSlash in the URLs.
If you are curious, this is the next.config.ts I used:
Hello @anshumanb , I added the next.config.tsfile in the root of the main site (www.tcblabber.cn), copied and pasted the above code in it. It didn’t work too. This is the deployment: 2wLEcMMX6. Is it the right way to create the next.config.ts file?