From bd9c8eac4c64d5d0bfbd392957a6b5fc6a6734d1 Mon Sep 17 00:00:00 2001 From: Baptiste Arnaud Date: Sun, 6 Aug 2023 11:20:13 +0200 Subject: [PATCH] :green_heart: Add conditional rewrites for NEXTAUTH_URL targets --- apps/viewer/next.config.js | 79 ++++++++++++++++++++++---------------- 1 file changed, 45 insertions(+), 34 deletions(-) diff --git a/apps/viewer/next.config.js b/apps/viewer/next.config.js index 5518859ce34..da818474732 100644 --- a/apps/viewer/next.config.js +++ b/apps/viewer/next.config.js @@ -76,40 +76,51 @@ const nextConfig = { })) ) : [] - ).concat([ - { - source: '/api/typebots/:typebotId/blocks/:blockId/storage/upload-url', - destination: - '/api/v1/typebots/:typebotId/blocks/:blockId/storage/upload-url', - }, - { - source: - '/api/typebots/:typebotId/blocks/:blockId/steps/:stepId/sampleResult', - destination: `${process.env.NEXTAUTH_URL}/api/v1/typebots/:typebotId/webhookBlocks/:blockId/getResultExample`, - }, - { - source: '/api/typebots/:typebotId/blocks/:blockId/sampleResult', - destination: `${process.env.NEXTAUTH_URL}/api/v1/typebots/:typebotId/webhookBlocks/:blockId/getResultExample`, - }, - { - source: - '/api/typebots/:typebotId/blocks/:blockId/steps/:stepId/unsubscribeWebhook', - destination: `${process.env.NEXTAUTH_URL}/api/v1/typebots/:typebotId/webhookBlocks/:blockId/unsubscribe`, - }, - { - source: '/api/typebots/:typebotId/blocks/:blockId/unsubscribeWebhook', - destination: `${process.env.NEXTAUTH_URL}/api/v1/typebots/:typebotId/webhookBlocks/:blockId/unsubscribe`, - }, - { - source: - '/api/typebots/:typebotId/blocks/:blockId/steps/:stepId/subscribeWebhook', - destination: `${process.env.NEXTAUTH_URL}/api/v1/typebots/:typebotId/webhookBlocks/:blockId/subscribe`, - }, - { - source: '/api/typebots/:typebotId/blocks/:blockId/subscribeWebhook', - destination: `${process.env.NEXTAUTH_URL}/api/v1/typebots/:typebotId/webhookBlocks/:blockId/subscribe`, - }, - ]), + ) + .concat([ + { + source: + '/api/typebots/:typebotId/blocks/:blockId/storage/upload-url', + destination: + '/api/v1/typebots/:typebotId/blocks/:blockId/storage/upload-url', + }, + ]) + .concat( + process.env.NEXTAUTH_URL + ? [ + { + source: + '/api/typebots/:typebotId/blocks/:blockId/steps/:stepId/sampleResult', + destination: `${process.env.NEXTAUTH_URL}/api/v1/typebots/:typebotId/webhookBlocks/:blockId/getResultExample`, + }, + { + source: + '/api/typebots/:typebotId/blocks/:blockId/sampleResult', + destination: `${process.env.NEXTAUTH_URL}/api/v1/typebots/:typebotId/webhookBlocks/:blockId/getResultExample`, + }, + { + source: + '/api/typebots/:typebotId/blocks/:blockId/steps/:stepId/unsubscribeWebhook', + destination: `${process.env.NEXTAUTH_URL}/api/v1/typebots/:typebotId/webhookBlocks/:blockId/unsubscribe`, + }, + { + source: + '/api/typebots/:typebotId/blocks/:blockId/unsubscribeWebhook', + destination: `${process.env.NEXTAUTH_URL}/api/v1/typebots/:typebotId/webhookBlocks/:blockId/unsubscribe`, + }, + { + source: + '/api/typebots/:typebotId/blocks/:blockId/steps/:stepId/subscribeWebhook', + destination: `${process.env.NEXTAUTH_URL}/api/v1/typebots/:typebotId/webhookBlocks/:blockId/subscribe`, + }, + { + source: + '/api/typebots/:typebotId/blocks/:blockId/subscribeWebhook', + destination: `${process.env.NEXTAUTH_URL}/api/v1/typebots/:typebotId/webhookBlocks/:blockId/subscribe`, + }, + ] + : [] + ), } }, }