Deployment of site with SSR functionality #603
-
The documentation on deployment uses I'm specifically looking to host on render.com (the bundled config for Render works fine for a static site without SSR functionality, but then of course the SSR parts don't work). |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 5 replies
-
Hi @vs-it-admin — I recently moved my own business site onto Render, and it's a simple example of using both a static and a server endpoint in a single config (aka a hybrid deployment), so I'll share it below: services:
- type: web
name: whitefusion-site
env: static
buildCommand: bin/bridgetown deploy
staticPublishPath: ./output
pullRequestPreviewsEnabled: true
envVars:
- key: BRIDGETOWN_ENV
value: production
- fromGroup: whitefusion-prod-envs
headers:
- path: /*
name: X-Frame-Options
value: DENY
- path: /*
name: X-XSS-Protection
value: "1; mode=block"
- path: /*
name: X-Content-Type-Options
value: "nosniff"
- path: /*
name: Strict-Transport-Security
value: "max-age=15552000; includeSubDomains"
- path: /*
name: Referrer-Policy
value: "no-referrer-when-downgrade"
- path: /*
name: Cache-Control
value: "public, max-age=86400, s-max-age=86400"
routes:
- type: rewrite
source: /contact-form/*
destination: https://whitefusion-site-api.onrender.com/contact-form/*
- type: rewrite
source: /book-session/*
destination: https://whitefusion-site-api.onrender.com/book-session/*
- type: web
name: whitefusion-site-api
env: ruby
buildCommand: bundle install && yarn install && bin/bridgetown frontend:build
startCommand: bin/bridgetown start
envVars:
- key: BRIDGETOWN_ENV
value: production
- fromGroup: whitefusion-prod-envs There's actually some interesting problems getting solved here, which is why I haven't gotten a full guide written up yet along with an update to the automated Render config to handle hybrid deployments. Basically, the goal is to punch a few "holes" through the CDN of the static site, so that it can reference the server endpoint. That way you don't need to worry about anything on the frontend with regards to sharing cookies cross-domain, CORS, etc. In this example, POSTing to https://www.whitefusion.studio/contact-form/ will essentially get rewritten under the hood to hit the server API. My hope is come up with an automated solution where if you comment your Roda routes to generate a routes manifest, it can then update the YAML file automatically with all the rewrite paths. That way you won't have to manually track which paths need to be specified. Of course you could always put all your SSR'd paths under a top-level name like Let me know if that makes sense… |
Beta Was this translation helpful? Give feedback.
Hi @vs-it-admin — I recently moved my own business site onto Render, and it's a simple example of using both a static and a server endpoint in a single config (aka a hybrid deployment), so I'll share it below: