This project can be used to run in front of Cloudflare Pages or any static site. It takes incoming requests to the homepage and redirects them to /{the users language}. This is made to be used in conjunktion with something like gatsby-plugin-react-i18next for GatsbyJS so your users will have a fast redirect when landing on your site, but you can also have this worker run in front of any other "traditional" site to cut down in initial response times when users have to be redirected to a localized version of the page first.
Click the following button:
After that continue with "How to configure?".
To manually deploy this worker you will need to fork this repo and add CF_ACCOUNT_ID and CF_API_TOKEN to your repository actions secrets, containing your Cloudflare Account ID and an API-Key created with the "Edit Cloudflare Workers"-preset, so the GitHub Action will work.
To get started open config.js
by clicking the little pen icon on GitHub or by cloning the repo to your local computer and editing the file.
You will then need to fill in the default language, the supported languages, and the paths the redirector should be active at. The paths should be your landing pages, so users will be redirected fast on those.
Visit the Cloudflare Workers Zone settings to have the worker run in front of your site by setting up Worker Routes.