Created
November 22, 2024 12:11
-
-
Save IrealiTY/24f8eccbfe4386f9c5684c44390e5c46 to your computer and use it in GitHub Desktop.
.well-known Cloudflare Worker for bluesky subdomains
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
addEventListener('fetch', event => { | |
event.respondWith(handleRequest(event.request)) | |
}) | |
async function handleRequest(request) { | |
const url = new URL(request.url) | |
// Only respond to /.well-known/atproto-did requests | |
if (url.pathname !== '/.well-known/atproto-did') { | |
return new Response('Not Found', { status: 404 }) | |
} | |
// Get subdomain from hostname | |
const subdomain = url.hostname.split('.')[0] | |
const didMap = { | |
'yoursubomain': 'did:plc:your_did_here' // Replace with your actual DID | |
// Add more subdomains and DIDs as needed | |
// 'subdomain': 'did:plc:...', | |
} | |
if (didMap[subdomain]) { | |
return new Response(didMap[subdomain], { | |
headers: { | |
'Content-Type': 'text/plain', | |
'Cache-Control': 'max-age=3600' | |
} | |
}) | |
} | |
return new Response('DID not found', { | |
status: 404, | |
headers: { | |
'Content-Type': 'text/plain' | |
} | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
*yourdomain.net/.well-known/atproto-did