Redirect to another netlify site with nuxt doesn't load correctly

So, inside my Netlify account (same team) I have two different websites.

The main website is:
https://entertainyou.netlify.app

The detail website is:
https://wtf-lmey.netlify.app

On the main website I have a redirect set in the netlify.toml

[[redirects]]
from="/gameroom/wtf/*" 
to = "https://wtf-lmey.netlify.app/:splat"
status = 200

I need the URL in the address bar to remain unchanged, but the detail website should be served.

The redirect is working and the URL remains the same. However, the page that is living on the second URL is not working properly.

It returns several 404 on images, .js files and so on. Only the static HTML is rendered. If I visit the second website directly, everything works just fine.

Both websites run a Nuxt website.

What am I missing here?

Hi @Jeffrey1586

Everything works when you visit https://wtf-lmey.netlify.app directly, but not when proxying via https://entertainyou.netlify.app/gameroom/wtf/ because (by default) Nuxt builds a site thinking visitors will access it via the domain root (/.) As you wish to access it via a different path (/gameroom/wtf/) you would need to change the base directory for the production site.

This has the downside of the site no longer working at the root of the domain i.e. Rather than accessing it via https://wtf-lmey.netlify.app it would live at https://wtf-lmey.netlify.app/gameroom/wtf/ too. This is fine if you don’t want anyone directly accessing the site via this domain.

But it does find the static file. So somehow, the proxy is working, it just has troubles with external files.

When you load the site hosted at https://wtf-lmey.netlify.app/ from your main site via https://entertainyou.netlify.app/gameroom/wtf/ the issue is that images and other assets won’t load. This is because all path such as

<img src="/WTF_welcome.jpg" class="welcomeIMG relative z-10" data-v-320f08fa="">

become relative to the main site https://entertainyou.netlify.app/WTF_welcome.jpg not the second site https://wtf-lmey.netlify.app/WTF_welcome.jpg. This is why requests to these assets show as 404 Not Found

1 Like