type
status
date
slug
summary
tags
category
icon
password
搭建后端服务图文教程
- 新建
Workers
命名为cyi-service
(也可以自己随便命名)点击部署
![notion image](https://www.notion.so/image/https%3A%2F%2Fprod-files-secure.s3.us-west-2.amazonaws.com%2F78e60bf6-694d-4c51-9a70-87ef76f09217%2F73b76783-9ad8-47eb-a278-e64b2e13e366%2Fimage.png?table=block&id=117ee568-45a2-80c4-bf80-e1f3a4c20928&t=117ee568-45a2-80c4-bf80-e1f3a4c20928&width=679.984375&cache=v2)
- 下载并解压 复制
worker.js
内的内容 粘贴 点击部署
![notion image](https://www.notion.so/image/https%3A%2F%2Fprod-files-secure.s3.us-west-2.amazonaws.com%2F78e60bf6-694d-4c51-9a70-87ef76f09217%2F59b6819b-59b3-4c6f-a59e-1c5ea9ec975d%2Fimage.png?table=block&id=117ee568-45a2-80be-8be2-c253294a24f5&t=117ee568-45a2-80be-8be2-c253294a24f5&width=679.953125&cache=v2)
- 绑定
KV
以及D1
创建
KV
并绑定:![notion image](https://www.notion.so/image/https%3A%2F%2Fprod-files-secure.s3.us-west-2.amazonaws.com%2F78e60bf6-694d-4c51-9a70-87ef76f09217%2Fad90b2e8-96ba-4913-bb91-9bc24cc2c2d5%2F46cb8616-4543-4b72-b225-f0021bba6f1d.png?table=block&id=117ee568-45a2-8055-a6b7-f08fd4f65d33&t=117ee568-45a2-8055-a6b7-f08fd4f65d33&width=576.8329718004338&cache=v2)
![notion image](https://www.notion.so/image/https%3A%2F%2Fprod-files-secure.s3.us-west-2.amazonaws.com%2F78e60bf6-694d-4c51-9a70-87ef76f09217%2Ffb000c0e-9f2a-4506-b8db-d59d27a2bd35%2Fimage.png?table=block&id=117ee568-45a2-8018-830a-e1aedc50e119&t=117ee568-45a2-8018-830a-e1aedc50e119&width=672&cache=v2)
创建
D1
数据库并初始化数据表:![notion image](https://www.notion.so/image/https%3A%2F%2Fprod-files-secure.s3.us-west-2.amazonaws.com%2F78e60bf6-694d-4c51-9a70-87ef76f09217%2F3fa0ca7f-c9da-43dd-ba7b-06e13519f53a%2Fimage.png?table=block&id=117ee568-45a2-8056-808a-fbcc4dfc8bbd&t=117ee568-45a2-8056-808a-fbcc4dfc8bbd&width=638.96875&cache=v2)
创建成功后到控制台依次执行下面的
sql
:![notion image](https://www.notion.so/image/https%3A%2F%2Fprod-files-secure.s3.us-west-2.amazonaws.com%2F78e60bf6-694d-4c51-9a70-87ef76f09217%2F9d4c8589-a383-43a8-8aac-a162b72acb86%2Fimage.png?table=block&id=117ee568-45a2-804d-831c-d44d0337479e&t=117ee568-45a2-804d-831c-d44d0337479e&width=679.984375&cache=v2)
执行完成后应该下图这样的
![notion image](https://www.notion.so/image/https%3A%2F%2Fprod-files-secure.s3.us-west-2.amazonaws.com%2F78e60bf6-694d-4c51-9a70-87ef76f09217%2F526607b9-dda5-4bcd-a3e4-f06a0e517203%2Fimage.png?table=block&id=117ee568-45a2-800a-a78a-dde4e71a3363&t=117ee568-45a2-800a-a78a-dde4e71a3363&width=679.953125&cache=v2)
然后进行绑定
![notion image](https://www.notion.so/image/https%3A%2F%2Fprod-files-secure.s3.us-west-2.amazonaws.com%2F78e60bf6-694d-4c51-9a70-87ef76f09217%2Fd4ce6a13-b5e1-45c1-a555-7aed9d08eef5%2Fimage.png?table=block&id=117ee568-45a2-804b-a139-ec00e9b4f86e&t=117ee568-45a2-804b-a139-ec00e9b4f86e&width=679.921875&cache=v2)
- 添加变量
JWT_SECRET
值自己定:
![notion image](https://www.notion.so/image/https%3A%2F%2Fprod-files-secure.s3.us-west-2.amazonaws.com%2F78e60bf6-694d-4c51-9a70-87ef76f09217%2F39c98882-5aa4-49fb-918c-509f158eca4d%2Fimage.png?table=block&id=117ee568-45a2-800c-9fa1-dac1864bb91d&t=117ee568-45a2-800c-9fa1-dac1864bb91d&width=679.953125&cache=v2)
如果你需要添加鉴黄
api
(前提是你有moderatecontent
的api key
现在好像都找不到登录入口了)添加变量ModerateContentApiKey
值为api key
- 测试部署是否成功:
访问你的
workers
地址加/test
出现下图则代表部署成功![notion image](https://www.notion.so/image/https%3A%2F%2Fprod-files-secure.s3.us-west-2.amazonaws.com%2F78e60bf6-694d-4c51-9a70-87ef76f09217%2Fddae01a9-e5d6-45a0-94ca-4ecbc25d737e%2Fimage.png?table=block&id=117ee568-45a2-801e-89ba-eb5b83514bcd&t=117ee568-45a2-801e-89ba-eb5b83514bcd&width=358&cache=v2)
总结:
变量名 | 说明 | 值 |
JWT_SECRET | 秘钥 | 自己定义 |
ModerateContentApiKey | 鉴黄 api 配置 | moderatecontent 官网获取(现在已找不到入口) |
CYI_IMGDB | D1 数据库 | 绑定你创建的数据库名 |
CYI_IMGKV | KV 空间 | 绑定你创建的 KV |
前端部署教程
敬请期待…
- 作者:IMyself
- 链接:https://blog.lmyself.top/article/117ee568-45a2-8049-aa2a-fe2b5245fb51
- 声明:本文采用 CC BY-NC-SA 4.0 许可协议,转载请注明出处。
相关文章