Skip to content
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

SSR Site construct support for base path option #2964

Open
Ankcorn opened this issue Jun 8, 2023 · 8 comments
Open

SSR Site construct support for base path option #2964

Ankcorn opened this issue Jun 8, 2023 · 8 comments

Comments

@Ankcorn
Copy link

Ankcorn commented Jun 8, 2023

All the SSR frameworks support rendering on a base path like

example.com/docs

I can't get this working with sst :(

@jayair
Copy link
Contributor

jayair commented Jun 10, 2023

Hey Thomas, can you post this on #help and we'll take a look at supporting it.

@jplwood
Copy link
Contributor

jplwood commented Dec 14, 2023

@jayair Any updates on this? Searching discord just turns up workarounds and callouts that basePath isn't currently supported. We use basePath extensively with multiple apps behind a reverse proxy, so not having having basePath is certainly a hindrance!

@jayair
Copy link
Contributor

jayair commented Dec 16, 2023

I think this is supported for Astro and maybe Next.js. Which one are you looking for?

@jplwood
Copy link
Contributor

jplwood commented Dec 16, 2023

Next.js, yeah, we use it in our app's Next config, but when deployed with SST, that basePath isn't used as a prefix in cloudfront (specifically the app looks for static bundles at <basePath>/.next/*, but the cloudfront route has it as .next/*). That was at least one obvious issue I noticed, not sure if there are other places it should apply?

I've got a workaround for now, but certainly would be nice if the next construct used it when defining the CF routing rules!

@jayair
Copy link
Contributor

jayair commented Dec 20, 2023

Let me check on the Next.js one with the team.

@jplwood
Copy link
Contributor

jplwood commented Jan 9, 2024

I derped/lied. My workaround doesn't actually solve the issue. Regarding what I said before:

We use basePath extensively with multiple apps behind a reverse proxy

Without base path support, my next app will request all static bundles and such from the root path /. When behind a reverse proxy, the routing rules will have no idea that the / root requests should be routed to my app without putting all requests behind a basePath. Those requests will be sent to the default routing rule.

So this remains a big hindrance.


Curiously. I was just poking around again and I found this deprecated NextjsSite construct (as far as I can tell, it's deprecated because the non-deprecated construct uses SsrSite as a base, whereas the deprecated one doesn't?), and found that this deprecated version actually does support basePath. So this seems to be a regression.

@jplwood
Copy link
Contributor

jplwood commented Jan 9, 2024

@jayair since I figured out how basePath was previously done, went ahead and opened a suggested PR ☝️ to address at least the Next.js part of this issue.

@eschaefer
Copy link

eschaefer commented Apr 23, 2024

Just wanted to bump this, since using basePath with NextjsSite seems to result in 403 forbidden errors for static assets for me. Just curious if anyone else using basePath experiences this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants