Deploy this repo to your CloudFlare Pages,
Create a Worker KV,
Bind this Worker KV in your Pages project in Settings > Functions > KV namespaces bindings
with Variable name
called UrlShorten
,
Done
Setting | Value |
---|---|
Build command | npm run build |
Build output directory | /dist |
Root directory | / |
You could use any node version later than 16.
Variable name | Value |
---|---|
NODE_VERSION | 16.17.1 |
I assume you have created a KV namespace for this Pages project.
Variable name | KV namespace |
---|---|
UrlShorten | the one you created |
Other settings are not necessary.
Add it to KV like:
Key | Value |
---|---|
path | real url |
/blog |
https://blog.orangii.cn |
/more |
https://example.org |
Check this out:
https://cz.cyou/avatar/02e96d02a7364a53f44168f4beb7067c
Test with this README.md
- Origin: https://raw.githubusercontent.com/Jiaocz/CloudFlare-Pages-UrlShorten/feat/functions-dir/README.md
- Mirror: https://cz.cyou/gh/https://raw.githubusercontent.com/Jiaocz/CloudFlare-Pages-UrlShorten/feat/functions-dir/README.md
Just add origin link to cz.cyou (or your deployed instance).
https://cz.cyou/gh/${origin_link}
Github Mirror function from hunshcn/gh-proxy