Skip to content

Commit f5b14d3

Browse files
committed
feat(cors): Allow cross origin verification requests
1 parent 8d890e0 commit f5b14d3

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

main_test.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,3 +143,15 @@ func TestUnknownHandleRedirectsToDestination(t *testing.T) {
143143
assert.Equal(t, "https://example.com/register?handle=carol.example.com", url.String())
144144

145145
}
146+
147+
func TestDidEndpointAllowsCrossOriginRequests(t *testing.T) {
148+
router, _ := NewTestEnvironment()
149+
150+
res := httptest.NewRecorder()
151+
req, _ := http.NewRequest("GET", "https://alice.example.com/.well-known/atproto-did", nil)
152+
router.ServeHTTP(res, req)
153+
154+
assert.Equal(t, http.StatusOK, res.Code)
155+
assert.Equal(t, "did:plc:example001", res.Body.String())
156+
assert.Equal(t, "*", res.Header().Get("Access-Control-Allow-Origin"))
157+
}

router.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ func VerifyHandle(c *gin.Context) {
100100
return
101101
}
102102

103+
c.Header("Access-Control-Allow-Origin", "*")
103104
c.String(http.StatusOK, string(result.DecentralizedID))
104105
}
105106

0 commit comments

Comments
 (0)