Answer the question
In order to leave comments, you need to log in
How to host SPA on CDN?
There is an application on react (gatsby), a bundle of several html/css/js/json/images is assembled.
There is a droplet (virtualka) in DigitalOcean and a connected cdn in the same place.
Now: deployed in the simplest way: the static is in /var/www/mysite, nginx is up, which serves the static from this directory. In the same place, a Let's Encrypt certificate is added via certbot.
As you wish: all static files (the entire project) are uploaded to the CDN, the URL remains the same, the application works, users are happy. I googled the question, but I only find recipes for ready-made services that do all the configuration under the hood.
Answer the question
In order to leave comments, you need to log in
The easiest option is to leave everything as it is, add Cloudflare as a CDN. If you want something a little more fashionable, see https://geekflare.com/best-static-site-hosting-pla... .
UPDATE: they write that for a couple of years now you can do this with Cloudflare Workers https://www.coywolf.news/webmaster/cloudflare-stat... , I haven't tried it myself.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question