@@ -86,9 +86,13 @@ export default {
8686 const { pathname, searchParams } = url ;
8787
8888 if ( pathname . startsWith ( "/canary/" ) ) {
89+ if ( request . method === "OPTIONS" ) {
90+ return new Response ( null , { status : 204 , headers : corsHeaders ( ) } ) ;
91+ }
92+
8993 const token = pathname . slice ( "/canary/" . length ) . split ( "/" ) [ 0 ] ;
9094 if ( ! token ) {
91- return new Response ( "Not found" , { status : 404 } ) ;
95+ return new Response ( "Not found" , { status : 404 , headers : corsHeaders ( ) } ) ;
9296 }
9397
9498 const src = textOrEmpty ( searchParams . get ( "src" ) || "" ) ;
@@ -133,7 +137,7 @@ export default {
133137 const rateKey = `rl:${ token } :${ ipHash } :${ windowId } ` ;
134138 const rateCount = Number ( await env . KANARI_KV . get ( rateKey ) ) || 0 ;
135139 if ( rateCount >= rateLimitMax ) {
136- return new Response ( null , { status : 204 } ) ;
140+ return new Response ( null , { status : 204 , headers : corsHeaders ( ) } ) ;
137141 }
138142 await env . KANARI_KV . put ( rateKey , String ( rateCount + 1 ) , {
139143 expirationTtl : rateLimitWindow ,
@@ -207,7 +211,7 @@ export default {
207211 console . error ( "kanariya_error" , err ) ;
208212 }
209213
210- return new Response ( null , { status : 204 } ) ;
214+ return new Response ( null , { status : 204 , headers : corsHeaders ( ) } ) ;
211215 }
212216
213217 if ( pathname === "/admin/export" ) {
0 commit comments