diff --git a/frontend/next.config.js b/frontend/next.config.js index 5215715101..97abec8f6d 100644 --- a/frontend/next.config.js +++ b/frontend/next.config.js @@ -58,24 +58,32 @@ module.exports = async phase => { ], }, async redirects() { - const processorURLWithoutSSL = `http://processor.${process.env.KITSPACE_DOMAIN}${process.env.KITSPACE_EXTERNAL_PORT}` + const sslWorkaround = url => { + url = new URL(url) + url.protocol = 'http:' + return url.toString().slice(0, -1) // remove the trailing slash + } // we use "_" as the project name when there is only one project but we // don't want it to appear in the URL of the project page return [ - // Make the 1-click-bom.tsv file accessible to the 1-click-bom extension. { - source: '/:user/:repo/:project/1-click-BOM.tsv', - destination: `${processorURLWithoutSSL}/files/:user/:repo/HEAD/:project/1-click-BOM.tsv`, + source: '/:user/:repo/_', + destination: '/:user/:repo', permanent: true, }, + // Make the 1-click-bom.tsv file accessible to the 1-click-bom extension. { - source: '/:user/:repo/1-click-BOM.tsv', - destination: `${processorURLWithoutSSL}/files/:user/:repo/HEAD/_/1-click-BOM.tsv`, + source: '/:user/:repo/:project/1-click-BOM.tsv', + destination: `${sslWorkaround( + process.env.KITSPACE_PROCESSOR_URL, + )}/files/:user/:repo/HEAD/:project/1-click-BOM.tsv`, permanent: true, }, { - source: '/:user/:repo/_', - destination: '/:user/:repo', + source: '/:user/:repo/1-click-BOM.tsv', + destination: `${sslWorkaround( + process.env.KITSPACE_PROCESSOR_URL, + )}}/files/:user/:repo/HEAD/_/1-click-BOM.tsv`, permanent: true, }, ]