📌 📄 内容摘要:
jiangly (@QAWS12g) 在 Cloudflare worker 如何获取环境变量 中发帖
最近在学习使用cloudflare,现在环境变量的获取出现问题,如下:
[image]
worker代码,报的是Unauthorized
export default {
async fetch(request, env) {
const url = new URL(request.url);
const key = url.pathname.slice(1);
const API_KEY = env.API_KEY;
// 基本的 API 密钥验证
const providedApiKey = request.headers.get('X-API-Key');
if (providedApiKey !== API_KEY) {
return new Response('Unauthorized', { status: 401 ...
────────── 链接信息 ──────────
🔗 论坛链接: linux.do
📎 访问地址: https://linux.do/t/topic/259565/1
─────────────────────────────
📢 来源:LINUX DO