So, as usual, something new is buzzing around - JAMstack. My experience of buzzy new ideas is that they may or may not be useful, but generally not for the reasons the proponent gives, sorry to be a pessimist. Serving static website from a CDN instead of maintaining a server - seems like a good idea, now I don't need to support my own server and it's no longer a fullstack app. However, let's assume that the app needs to access google maps for instance to show users directions to their business. How does the JAMstack app secure the api key ? Lets assume this is an app for a small business
The simplest answer is that you do support a server which sends an api key to the app on load. For a static app the hosting company will have a mechanism for setting unix local variables that can be read or passed into the app when it is sent to the browser. This is the usually recommended method for securing api keys. Now the app can no longer be served from a cdn.
One answer I found is that for some apis, an api key can have a restriction that it can only be used from a specific domain. I think this would be set when the api key is generated. The referring domain could be spoofed however.
Another answer would be to have a function/lambda server that allows the previous mechanism to work - checks the domain of the caller and issues api key if it matches. No maintenance, or very little because Murphy's law always applies.
I am assuming that third party api supports cors (i.e. browser can access third party sites)
I would like to hear other ideas.