Skip to content
This repository has been archived by the owner on Oct 21, 2024. It is now read-only.

feat(aws/static-site): support routes arg #320

Closed
wants to merge 4 commits into from

Conversation

NamesMT
Copy link
Contributor

@NamesMT NamesMT commented Apr 27, 2024

Refactored to use Router under-the-hood :D, tested locally with working dev, HMR, deploy.
Resolves sst/sst#4711

Tested used without routes arg. (like current)
Tested with routes from APIGatewayV2, Function

@NamesMT
Copy link
Contributor Author

NamesMT commented Apr 27, 2024

Example snippet of the routes usage:

const backend = new sst.aws.Function('Backend', {
  url: true,
  handler: 'apps/backend/src/index.handler',
})

const staticSiteDistribution = new sst.aws.StaticSite('StaticFullstack', {
  build: {
    command: 'pnpm run build --filter="frontend"',
    output: 'apps/frontend/.output/public',
  },
  routes: {
    '/api/*': backend.url,
  },
})

This deploys my starter-fullstack template to Cloudfront, with the static frontend and Hono backend served on the same domain, with working Live development access from Cloudfront's url.

NamesMT

This comment was marked as off-topic.

@NamesMT
Copy link
Contributor Author

NamesMT commented Apr 30, 2024

Note: this update if merged as-is will remove and re-create the distribution for existing deploys.

@bodhihawken
Copy link

Love it when someone already has a PR for something i wanted to add. +1

@jayair jayair requested a review from fwang June 8, 2024 00:37
@fwang
Copy link
Contributor

fwang commented Oct 16, 2024

@NamesMT refactoring to use Router will cause the distribution to be removed and recreated.

That said, we have plans to attach a site to a router, and you can add additional routes.

But for now, we are moving sst/ion -> sst/sst and unfortunately this is going to be a messy process because of github's limitations

i'm going to close this PR for now and it can be re-opened in the new sst/sst repo that will be ready in the next few days if still relevant

@fwang fwang closed this Oct 16, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Static frontend + API/Function
3 participants