A container registry that uses the AT Protocol for manifest storage and S3 for blob storage. atcr.io
docker container atproto go
81
fork

Configure Feed

Select the types of activity you want to include in your feed.

add cors middleware

+26 -9
+26 -9
pkg/hold/pds/xrpc.go
··· 32 32 } 33 33 } 34 34 35 + // corsMiddleware wraps a handler with CORS headers 36 + func corsMiddleware(next http.HandlerFunc) http.HandlerFunc { 37 + return func(w http.ResponseWriter, r *http.Request) { 38 + w.Header().Set("Access-Control-Allow-Origin", "*") 39 + w.Header().Set("Access-Control-Allow-Methods", "GET, POST, OPTIONS") 40 + w.Header().Set("Access-Control-Allow-Headers", "Content-Type, Authorization") 41 + 42 + // Handle preflight OPTIONS requests 43 + if r.Method == http.MethodOptions { 44 + w.WriteHeader(http.StatusOK) 45 + return 46 + } 47 + 48 + next(w, r) 49 + } 50 + } 51 + 35 52 // RegisterHandlers registers all XRPC endpoints 36 53 func (h *XRPCHandler) RegisterHandlers(mux *http.ServeMux) { 37 54 // Health check endpoint 38 - mux.HandleFunc("/xrpc/_health", h.HandleHealth) 55 + mux.HandleFunc("/xrpc/_health", corsMiddleware(h.HandleHealth)) 39 56 40 57 // Standard PDS endpoints 41 - mux.HandleFunc("/xrpc/com.atproto.server.describeServer", h.HandleDescribeServer) 42 - mux.HandleFunc("/xrpc/com.atproto.repo.describeRepo", h.HandleDescribeRepo) 43 - mux.HandleFunc("/xrpc/com.atproto.repo.getRecord", h.HandleGetRecord) 44 - mux.HandleFunc("/xrpc/com.atproto.repo.listRecords", h.HandleListRecords) 58 + mux.HandleFunc("/xrpc/com.atproto.server.describeServer", corsMiddleware(h.HandleDescribeServer)) 59 + mux.HandleFunc("/xrpc/com.atproto.repo.describeRepo", corsMiddleware(h.HandleDescribeRepo)) 60 + mux.HandleFunc("/xrpc/com.atproto.repo.getRecord", corsMiddleware(h.HandleGetRecord)) 61 + mux.HandleFunc("/xrpc/com.atproto.repo.listRecords", corsMiddleware(h.HandleListRecords)) 45 62 46 63 // Sync endpoints 47 - mux.HandleFunc("/xrpc/com.atproto.sync.listRepos", h.HandleListRepos) 64 + mux.HandleFunc("/xrpc/com.atproto.sync.listRepos", corsMiddleware(h.HandleListRepos)) 48 65 49 66 // Blob endpoints (wrap existing presigned URL logic) 50 - mux.HandleFunc("/xrpc/com.atproto.repo.uploadBlob", h.HandleUploadBlob) 51 - mux.HandleFunc("/xrpc/com.atproto.sync.getBlob", h.HandleGetBlob) 67 + mux.HandleFunc("/xrpc/com.atproto.repo.uploadBlob", corsMiddleware(h.HandleUploadBlob)) 68 + mux.HandleFunc("/xrpc/com.atproto.sync.getBlob", corsMiddleware(h.HandleGetBlob)) 52 69 53 70 // DID document 54 - mux.HandleFunc("/.well-known/did.json", h.HandleDIDDocument) 71 + mux.HandleFunc("/.well-known/did.json", corsMiddleware(h.HandleDIDDocument)) 55 72 } 56 73 57 74 // HandleHealth returns health check information