How-to
Website
Web app
Deploy to Vercel
This recipe has Vercel build a WebFluent site on every push and serve it. Vercel does not read the _headers file the build writes, so the headers go in vercel.json. You need a Vercel account and the project in a repository Vercel can read; the build command installs wf as Install wf on a build machine shows. Add vercel.json at the project's root. This one is for a single-page build:
{
"buildCommand": "curl --proto '=https' --tlsv1.2 -fsSL https://raw.githubusercontent.com/monzeromer-lab/WebFluent/master/install.sh | WF_VERSION=v7.1.1 bash && ~/.webfluent/bin/wf build",
"outputDirectory": "build",
"headers": [
{
"source": "/(.*)",
"headers": [
{ "key": "X-Content-Type-Options", "value": "nosniff" },
{ "key": "Referrer-Policy", "value": "strict-origin-when-cross-origin" },
{ "key": "X-Frame-Options", "value": "DENY" }
]
}
],
"rewrites": [{ "source": "/(.*)", "destination": "/index.html" }]
}
How it works
buildCommandinstallswfand builds the site;outputDirectorytells Vercel to servebuild/.headerssets the security headers on every path. Vercel does not read_headers, so copy every header the build wrote inbuild/_headersinto this list, including theContent-Security-Policyline (Set cache and security headers).rewritesanswers every path withindex.html, so a reload on a deep link reaches the single-page build's router.
Check it
Compare the response headers in the browser's network panel with build/_headers. Each header in the file should be there. Then go through Check a deploy.
Variations
For a static build, leave out rewrites: each page has its own file, and an unknown path should be a 404.