feat: 添加 Cloudflare Workers 支持
- 在 package.json 中添加 @cloudflare/vite-plugin 依赖 - 新增 server/index.ts 文件实现 Cloudflare Workers 逻辑 - 更新 vite.config.ts 配置,添加 cloudflare 插件 - 新增 tsconfig.worker.json 配置 TypeScript 编译选项 - 更新 App.vue,添加从 API 获取名称的功能
This commit is contained in:
12
server/index.ts
Normal file
12
server/index.ts
Normal file
@@ -0,0 +1,12 @@
|
||||
export default {
|
||||
fetch(request) {
|
||||
const url = new URL(request.url);
|
||||
|
||||
if (url.pathname.startsWith("/api/")) {
|
||||
return Response.json({
|
||||
name: "Cloudflare",
|
||||
});
|
||||
}
|
||||
return new Response(null, { status: 404 });
|
||||
},
|
||||
} satisfies ExportedHandler<Env>;
|
Reference in New Issue
Block a user