HACKER Q&A
📣 aristofun

How do you manage “static” pages on your micro SaaS website?


I wonder how small scale SaaS developers manage their static content on the same domain as a Web app.

I mean all those landing pages, legal, promo materials etc.

Yes, you can point domain.com -> netlify, while app.domain.com -> your frontend server.

But what if you need a bit more than that? Like use auth cookies, expose some web-app features, urls on root domain etc.

How do you combine all that with the rest of static pages' you want to keep updating at runtime without managing own CMS?

Any tools, libs, best practices?


  👤 the_biot Accepted Answer ✓
Holy shit, what a bunch of nonsense suggestions! SGML, React, S3?

You just put the whole thing behind an nginx (which it likely already is), and have it serve up the static content from a local filesystem, while routing your dynamic stuff however needed.


👤 schwartzworld
How about nginx? I've been playing with it recently and have been amazed what can be accomplished. You get very granular control over your requests and can easily route them to multiple ports or static file directories with support for server side includes.

👤 rozenmd
I built https://onlineornot.com entirely in Next.js

This lets me host my marketing pages as static pages, and the app pages at /app - works really well, no messing around with separate builds, would highly recommend it.


👤 kall
Two options: a reverse proxy or you serve both from the same system.

For reverse proxy you can go the old and trusted route with e.g. Nginx, go fully managed with something like external rewrites on Vercel, or even hack together your own thing with edge workers.

For all from one system, whatever you're using for your backend, be it React (with Next.js) or Ruby on Rails, can probably also serve any kind of static content, but it might not be worth intermingling that based on your situation.


👤 smokey_circles
Proxies. It's always proxies :D

My personal favorite pattern with HTTP is using nginx as the DNS endpoint for several hosts (root_domain, api.root_domain, tool.root_domain etc).

Nginx will forward traffic based on the HTTP Host header in any given correctly formed HTTP request. This also works well for a load balancer. I think the hip thing for today's market is itsio? Same basic idea.

Another benefit of an application layer proxy is you can do application layer things, like telling a client to redirect from http to https and serving https using let's encrypt. Privacy for free (state actor caveats apply).

Your applications (then one behind nginx) do not need to use transit layer encryption (unless of course they're connected to nginx via untrusted networks, be sensible) which is a huge boost because nginx do a good job implementing all of that logic for you and it's nice to hand off responsibility to trusted entities that do the job well.

Unless it's log4j, apparently.


👤 gls2ro
I don't have an answer to this but more like a thing to take into consideration:

I think when deciding to create this kind of architecture we should put in balance:

On one side:

- What do we gain from this: probably marketing/sales/UX and how much value this kind of architecture will create

On another side:

- The cost to implement this

+

- The cost to manage the complexity created by implementing this architecture

+

- The reduction of development speed due to coupling


👤 tannhaeuser
By using an embeddable SGML CMS, no less, as an express.js route [1]. Or, alternatively, as a command-line app for prerendering static HTML.

[1]: http://sgmljs.net


👤 herbst
At this point (needing any dynamic features) good caching and exposing a dynamic frontend basically serves the same purpose.

👤 pdyc
i have similar problem and i am trying to solve it with this https://github.com/newbeelearn/sserver . Next release is planned in june.

👤 pjs_
NGINX will do this just great.

👤 hoofhearted
Next.js for React, Nuxt.js for Vue is pretty amazing. Nuxt Content can serve static content like blog articles out of json files and server side render them.

👤 droobles
ejs templates with bootstrap, works for now. Maybe a cms later on