@@ -2,7 +2,7 @@ import type { ClerkMiddlewareAuth } from '@clerk/nextjs/server'
22import type { NextRequest } from 'next/server'
33import { NextResponse } from 'next/server'
44import { CS_COOKIE_NAME , type CtsToken } from '../index'
5- import { logger } from '../logger'
5+ import { logger } from '../../../utils/ logger'
66
77export const jseqlClerkMiddleware = async (
88 auth : ClerkMiddlewareAuth ,
@@ -25,10 +25,11 @@ export const jseqlClerkMiddleware = async (
2525 const workspaceId = process . env . CS_WORKSPACE_ID
2626
2727 if ( ! workspaceId ) {
28- const errorMessage =
29- 'CS_WORKSPACE_ID environment variable is not set, and is required by jseqlClerkMiddleware.'
30- logger . error ( errorMessage )
31- throw new Error ( `[ Server ] jseql: ${ errorMessage } ` )
28+ logger . error (
29+ 'The "CS_WORKSPACE_ID" environment variable is not set, and is required by jseqlClerkMiddleware. No CipherStash session will be set.' ,
30+ )
31+
32+ return NextResponse . next ( )
3233 }
3334
3435 const ctsEndoint =
@@ -47,9 +48,13 @@ export const jseqlClerkMiddleware = async (
4748 } )
4849
4950 if ( ! ctsResponse . ok ) {
50- throw new Error (
51- `[ Server ] jseql: Failed to fetch CTS token: ${ ctsResponse . statusText } ` ,
51+ logger . debug ( `Failed to fetch CTS token: ${ ctsResponse . statusText } ` )
52+
53+ logger . error (
54+ 'There was an issue communicating with the CipherStash CTS API, the CipherStash session was not set. If the issue persists, please contact support.' ,
5255 )
56+
57+ return NextResponse . next ( )
5358 }
5459
5560 const cts_token = ( await ctsResponse . json ( ) ) as CtsToken
0 commit comments