Trailing slash missing on proxied Netlify site

I have a number of sites hosted on Netlify and am in the process of migrating some, which were hosted on other domains, under subfolders. For this I’m using the request proxying feature (200 response).

For this I’m using the following pattern, on the “main” site, as described in the docs

/folder/* https://subsite.netlify.app/folder/:splat 200

With this setup, navigating to https://www.example.com/folder/ will correctly proxy and display the content from the target server. Unfortunately, so will navigating to https://www.example.com/folder (no trailing slash) – without redirecting. This caused problems with CSS resources/etc. although this was fixable using absolute paths.

(as an aside I’m not even sure why /folder would redirect when the rule specifies /folder/*)

However, this issue also affects all sub-pages, e.g. https://www.example.com/folder/two will not redirect to https://www.example.com/folder/two/ – regardless of the pretty URL settings on the sub site.

What’s even more weird is if I load up the subsite directly, the trailing slashes are handled correctly. For some reason this behaviour is not being passed through the proxying.

This has implications for duplicate content etc. so I would like to fix it. Any tips?

1 Like

Hey! So, I’ve covered this quite a bit in the past, including this support guide: [Support Guide] How can I alter trailing slash behaviour in my URLs? Will enabling Pretty URLs help?

You’ll want to check out the section “my SSG uses static routing” which explains exactly what you’re seeing. In short, URLs are normalised so /folder/ is treated the same as /folder.

Without knowing your site, you may also want to be conscious of whether shadowing is necessary or not (whether you need to force the rule or not because the page, asset or resource exists on the originating site).

Plenty of food for thought and I’d be happy to take a look-see with particular real world cases or answer any follow-ups!

Thanks for the reply @Scott but I don’t think this is related to the guide you linked to. This is specifically about the behaviour when using a _redirects proxy to a second Netlify site.

On the “parent” site, all folders work as expected. The site is as you say a completely static site with /folder/index.html structure, and /folder redirects to /folder/.

The “child” site, which is being proxied to is also a completely static site, with the /folder/index.html structure. Navigating on that site correctly displays the correct behaviour (navigating to /folder redirects to /folder/).

The issue is that these redirects do not work once proxied. So if on the parent site I navigate to www.example.com/myproxysite/folder it will no longer redirect to www.example.com/myproxysite/folder/

I submitted a ticket to support and got this reply from Luke

This is a known issue and we do have an open bug filed for this. I’ve added you to the internal issue (bug report) and we will contact you at this email address to let you know if or when it is resolved. At this time, there is no workaround for this issue.

1 Like

Cheers for the context, @mfitzp! Luke is very much on the money, this is a known issue.

The only thing I could think to try would be to actually enable asset optimisation in the UI (untick ‘Disable asset optimisation’). It’s unlikely to impact or improve this however there’s no harm in trying everything, eh? :slight_smile:

Is it possible that this issue is still open? We experience the exact same issue and I could not find a way to get it working. We have Pretty URLs enabled.

Hi, @mfitzp. You are correct that the issue is still open and it’s cross-linked with this topic for tracking. I looked for any workaround for this but there is no alternative at this time - except not to proxy which isn’t an option in most cases.

If the issue is known to be resolved, we will post an update in this topic to let you know.

This issue has a duplicate No trailing slash when using proxies. I’m seeing the same bug.