## Worker名称 name = "aka" ## 项目配置信息,不要修改 type = "javascript" ## accound_id 必须修改 可以在 「 Domain - API - Account ID 」 找到 account_id = "<account_id>" ## worker.dev 域名分配,可关闭 workers_dev = true ## cloudflare route,若绑定自己域名需修改<domain>为自己域名 route = "<domain>/*" ## zone_id 只有在需要绑定域名时填写,可以在 「 Domain - API - Zone ID 」找到。 zone_id = "<zone_id>" ## <kv id> 填写为下文挂载的 kv kv_namespaces = [ { binding = "__aka__", id = "<kv id>" } ]
新建 KV 并挂载到对应项目
这里使用 wrangler 新建 kv
1 2 3 4 5
$ wrangler kv:namespace create __aka__ 🌀 Creating namespace with title "aka-__aka__" ✨ Success! Add the following to your configuration file in your kv_namespaces array: { binding = "__aka__", id = "*********" }
将 id 的内容复制到上处 wrangler.toml 的 <kv id>。
部署后端 🚀
当你已经确保本地的配置已经没有问题时,可以准备部署该项目了。
1 2 3 4
$ wrangler publish ✨ JavaScript project found. Skipping unnecessary build! ✨ Successfully published your script to 16sl.ga/* => stayed the same
(node:16309) ExperimentalWarning: The ESM module loader is experimental.
$ wrangler publish
⚠️ The following routes in your configuration file should have a trailing * to apply the Worker on every path, otherwise your site will not behave as expected. 16sl.ga/sw.js 16sl.ga/ 16sl.ga/index.html ✨ Built successfully, built project size is 13 KiB. 🌀 Using namespace for Workers Site "__aka_frontend-workers_sites_assets" ✨ Success 🌀 Uploading site files ✨ Successfully published your script to 16sl.ga/cdn-sources/* => stayed the same 16sl.ga/sw.js => stayed the same 16sl.ga/js/* => stayed the same 16sl.ga/css/* => stayed the same 16sl.ga/ => stayed the same 16sl.ga/index.html => stayed the same 16sl.ga/assets/* => stayed the same 16sl.ga/web_modules/* => stayed the same 16sl.ga/_dist_/* => stayed the same 16sl.ga/__snowpack__/* => stayed the same