From ce63c1c64afe970a4608772be8c8ecb65992e12a Mon Sep 17 00:00:00 2001 From: Christopher Pappas Date: Mon, 24 Feb 2020 09:24:33 -0800 Subject: [PATCH] Hard-code CDN for now --- Dockerfile | 2 -- .../apps/search/searchMiddleware.tsx | 1 + src/desktop/lib/global_client_setup.tsx | 23 +++++++++++++++---- webpack/envs/baseConfig.js | 2 -- 4 files changed, 20 insertions(+), 8 deletions(-) diff --git a/Dockerfile b/Dockerfile index 2f07b2390b0..4b8881b587e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,8 +2,6 @@ FROM node:12.14-alpine WORKDIR /app -ENV CDN_PRODUCTION_URL=https://d1s2w0upia4e9w.cloudfront.net CDN_STAGING_URL=https://d1rmpw1xlv9rxa.cloudfront.net - # Install system dependencies # Add deploy user RUN apk --no-cache --quiet add \ diff --git a/src/desktop/apps/experimental-app-shell/apps/search/searchMiddleware.tsx b/src/desktop/apps/experimental-app-shell/apps/search/searchMiddleware.tsx index 0e599366cab..3b86352f8d8 100644 --- a/src/desktop/apps/experimental-app-shell/apps/search/searchMiddleware.tsx +++ b/src/desktop/apps/experimental-app-shell/apps/search/searchMiddleware.tsx @@ -66,6 +66,7 @@ export const searchMiddleware = async (req, res, next) => { html: layout, } res.status(status).send(layout) + return } catch (error) { console.log(error) next(error) diff --git a/src/desktop/lib/global_client_setup.tsx b/src/desktop/lib/global_client_setup.tsx index d7baedd3a17..967d0d2b932 100644 --- a/src/desktop/lib/global_client_setup.tsx +++ b/src/desktop/lib/global_client_setup.tsx @@ -2,12 +2,27 @@ * Set webpack public-path asset lookup to CDN in production, but only on * the client, as we use the assetMiddleware helper to map URLs on the server. * @see https://github.com/artsy/force/blob/master/src/lib/middleware/assetMiddleware.ts + * + * FIXME: Move this into Circle config and or Docker */ if (process.env.NODE_ENV === "production") { - __webpack_public_path__ = - (window.location.hostname === "www.artsy.net" - ? process.env.CDN_PRODUCTION_URL - : process.env.CDN_STAGING_URL) + "/assets/" + const { hostname } = window.location + let cdnUrl + + // Production + if (hostname === "www.artsy.net") { + cdnUrl = "https://d1s2w0upia4e9w.cloudfront.net" + + // Localhost + } else if (hostname === "localhost") { + cdnUrl = "" + + // Everything else + } else { + cdnUrl = "https://d1rmpw1xlv9rxa.cloudfront.net" + } + + __webpack_public_path__ = cdnUrl + "/assets/" } import $ from "jquery" diff --git a/webpack/envs/baseConfig.js b/webpack/envs/baseConfig.js index 71b81941913..8d56878db8e 100644 --- a/webpack/envs/baseConfig.js +++ b/webpack/envs/baseConfig.js @@ -65,8 +65,6 @@ exports.baseConfig = { new webpack.DefinePlugin({ "process.env": { NODE_ENV: JSON.stringify(NODE_ENV), - CND_PRODUCTION_URL: JSON.stringify(process.env.CND_PRODUCTION_URL), - CDN_STAGING_URL: JSON.stringify(process.env.CDN_STAGING_URL), }, }), // Remove moment.js localization files