Only run functions on first page load?


Trying to add a CSP nonce for an inline script. I’ve put it in the _middleware.ts and it works fine, however it is also being run for all static assets - which is unnecessary and unwanted. The Pages project is a SPA application that can be accessed by both example dot com , example dot com/anything/?also_with_query_params=true
As what I see the _routes.json does not cover this?

To summarize: How to only run a Function on a Cloudflare Pages on page load

As far as I know, you cannot. The “functions” are like regular workers and are executed on every request, for everything.