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

BasePath support #494

Closed
rrooding opened this issue Jul 10, 2020 · 3 comments
Closed

BasePath support #494

rrooding opened this issue Jul 10, 2020 · 3 comments
Labels

Comments

@rrooding
Copy link
Contributor

rrooding commented Jul 10, 2020

I'm trying to use the Next.js basePath option (vercel/next.js#4998) with serverless-next.js but I'm having some problems.

Please let me know if I'm missing something but as far as I can see this is not supported yet.

I am happy to contribute a PR but would like to discuss the implementation first. My suggestion is to read the basePath setting from the next.config.js file during deployment and, when configured, use that for the following:

  • Change uploadAssetsToS3 to upload to <basePath>/ subdirectory in the bucket
  • Change the Cloudfront origins to <basePath>/_next/static/*, <basePath>/static/*, etc..

Anything else?

@danielcondemarin
Copy link
Contributor

danielcondemarin commented Jul 11, 2020

@rrooding A couple of thoughts from me on the approach:

  • Rather than reading from the next.config.js file its easier to read from .next/routes-manifest.json which contains the basePath property.

  • I'm not sure you actually need to a new directory in the s3 bucket. As long as the CloudFront cache behaviour maps <basePath>/_next/static/* -> s3 _next/static/* should be OK I think. Only saying because it may be simpler to implement to start with at least.

FYI - I've raised an RFC for multi-zones like support here that is sort of related.

Feel free to start a PR and I'll help out with approach and testing.

@rrooding
Copy link
Contributor Author

rrooding commented Aug 4, 2020

I was on holiday, but just got to fixing the last failure, if you could have a look at it again 👍

@rrooding
Copy link
Contributor Author

PR is merged

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

No branches or pull requests

2 participants