The Wayback Machine - https://web.archive.org/web/20210623200121/https://github.com/vercel/next.js/discussions/17581
Skip to content
2

ISG behind a reverse proxy that rewrites the URI #17581

fernandobandeira started this conversation in Ideas
ISG behind a reverse proxy that rewrites the URI #17581
Oct 3, 2020 · 1 comments · 1 reply

Bug report

Describe the bug

This bug originated from discussion #17260

We were exploring ways to use ISG on a multi-tenant app and thought that putting all pages inside a [hostname] param would do the trick, then we could have a reverse proxy on top of next.js to hide the [hostname] from the client URL.

There are 2 bugs with this approach

1 - Client-side routing is broken:
The client-side routing expects the hostname to be part of the URL and since we're hiding it, the user can't navigate between the pages anymore, what happens is that if the user tries to go to a page like /example, an example would be treated as the hostname and he'd be taken to the /[hostname] route instead of /[hostname]/example.

2 - The first generation doesn't work
The first static generation isn't triggered when using the reverse proxy so all of the requests see the fallback page, interesting enough if the page was generated previously or from another means it'll serve it just fine, it also regenerates the existing static page fine too, it's just the first generation that doesn't occur.

To Reproduce

You can test both bugs with this repo:

https://github.com/fernandobandeira/isg-next-poc-multi-tenant

There are reproduction steps there and I tried to make it really simple to set up and test the issues, please ping me if you have problems.

Expected behavior

I think it'd be nice to have this sorted out for multi-tenant apps, it'd be really great, although I'm not sure how many users would benefit from it, I imagine multi-tenant apps are common but maybe they aren't.

Another idea would be to add some built-in functionality to group the generated pages by the hostname that doesn't require the proxy. although I'm not sure that'd be possible since the generation is done without the request details apart from the path but maybe that could be builtin somehow.

Replies

1 comment
·
1 reply
1

I've spent the last couple of days experimenting trying to find a way to accomplish pretty much exactly this, I'd be really interested to see this feature.

1 reply
@nicosh

@fernandobandeira @calirvine you made any progress to accomplish this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
💡
Ideas
Labels
None yet
3 participants
Converted from issue
Beta