File tree Expand file tree Collapse file tree 1 file changed +9
-0
lines changed Expand file tree Collapse file tree 1 file changed +9
-0
lines changed Original file line number Diff line number Diff line change 3
3
const Hashids = require ( 'hashids' ) ;
4
4
const NODE_ENV = process . env . NODE_ENV ;
5
5
const isProduction = ( NODE_ENV === 'production' ) ;
6
+ const IGNORE_AUTH_PATH_REGEX = process . env . IGNORE_AUTH_PATH_REGEX || / ( w e b ) / ;
7
+
8
+ function isIgnoredPath ( path ) {
9
+ return path . search ( IGNORE_AUTH_PATH_REGEX ) >= 0 ;
10
+ }
6
11
7
12
function hashKeyMiddlewareWrapper ( options = {
8
13
salt : process . env . SALT || 'my salt' ,
@@ -14,6 +19,10 @@ function hashKeyMiddlewareWrapper (options = {
14
19
const HASHKEY_ALIVE_TIME = options . hashkeyAliveTime * 60 * 1000 ;
15
20
16
21
return function hashKeyMiddleware ( req , res , next ) {
22
+ if ( isIgnoredPath ( req . path ) ) {
23
+ return next ( ) ;
24
+ }
25
+
17
26
const hashKey = req . query . hashkey || req . query . access_token ;
18
27
const decodedKey = idHashids . decode ( hashKey ) ;
19
28
const ip = req . headers [ 'x-forwarded-for' ] || req . connection . remoteAddress ;
You can’t perform that action at this time.
0 commit comments