x-custom-tokenの値を検証し、その値がtoken-123456と等しい場合はアクセスを許可し、それ以外の場合はアクセスを拒否します。エッジ関数を使用してシンプルなアクセス制御を実装しています。async function handleRequest(request) {const token = request.headers.get('x-custom-token');if (token === 'token-123456') {return new Response('hello world');}// Incorrect key supplied. Reject the request.return new Response('Sorry, you have supplied an invalid token.', {status: 403,});}addEventListener('fetch', event => {event.respondWith(handleRequest(event.request));});


Esta página foi útil?
Você também pode entrar em contato com a Equipe de vendas ou Enviar um tíquete em caso de ajuda.
comentários