@@ -32,7 +32,7 @@ export const NO_AUTHORIZATION_ROUTES = [
32
32
"POST /auth/reset" ,
33
33
"GET /invites/" ,
34
34
// Routes with a seperate auth system
35
- / P O S T \/ w e b h o o k s \/ \d + \/ \w + \/ ? / , // no token requires auth
35
+ / ^ ( P O S T | H E A D ) \/ w e b h o o k s \/ \d + \/ \w + \/ ? / , // no token requires auth
36
36
// Public information endpoints
37
37
"GET /ping" ,
38
38
"GET /gateway" ,
@@ -51,11 +51,11 @@ export const NO_AUTHORIZATION_ROUTES = [
51
51
// Oauth callback
52
52
"/oauth2/callback" ,
53
53
// Asset delivery
54
- / G E T \/ g u i l d s \/ \d + \/ w i d g e t \. ( j s o n | p n g ) / ,
54
+ / ^ ( G E T | H E A D ) \/ g u i l d s \/ \d + \/ w i d g e t \. ( j s o n | p n g ) / ,
55
55
// Connections
56
- / P O S T \/ c o n n e c t i o n s \/ \w + \/ c a l l b a c k / ,
56
+ / ^ ( P O S T | H E A D ) \/ c o n n e c t i o n s \/ \w + \/ c a l l b a c k / ,
57
57
// Image proxy
58
- / G E T \/ i m a g e p r o x y \/ [ A - Z a - z 0 - 9 + / ] \/ \d + x \d + \/ .+ / ,
58
+ / ^ ( G E T | H E A D ) \/ i m a g e p r o x y \/ [ A - Z a - z 0 - 9 + / ] \/ \d + x \d + \/ .+ / ,
59
59
] ;
60
60
61
61
export const API_PREFIX = / ^ \/ a p i ( \/ v \d + ) ? / ;
@@ -82,6 +82,12 @@ export async function Authentication(
82
82
const url = req . url . replace ( API_PREFIX , "" ) ;
83
83
if (
84
84
NO_AUTHORIZATION_ROUTES . some ( ( x ) => {
85
+ if ( req . method == "HEAD" ) {
86
+ if ( typeof x === "string" )
87
+ return url . startsWith ( x . split ( " " ) . slice ( 1 ) . join ( " " ) ) ;
88
+ return x . test ( req . method + " " + url ) ;
89
+ }
90
+
85
91
if ( typeof x === "string" )
86
92
return ( req . method + " " + url ) . startsWith ( x ) ;
87
93
return x . test ( req . method + " " + url ) ;
0 commit comments