From eccae3f26d32595f2b510ee9120fb672986e73f6 Mon Sep 17 00:00:00 2001 From: John Wu <76966357+jwu-fisker@users.noreply.github.com> Date: Tue, 26 Jan 2021 17:35:39 -0800 Subject: [PATCH] Remove default localhost settings (#8) * Remove default localhost settings Replace with deployment settings * Fix for upload data format * Fix test data for last commit --- .env.template | 2 +- Dockerfile | 1 - src/components/Contexts/FileUploadContext.jsx | 2 +- src/services/__mocks__/uploadFile.js | 2 +- src/services/uploadFile.js | 2 +- 5 files changed, 4 insertions(+), 5 deletions(-) diff --git a/.env.template b/.env.template index 4883d8e..de94a3c 100644 --- a/.env.template +++ b/.env.template @@ -1,2 +1,2 @@ REACT_APP_AUTH_SERVICE_URL = https://dev-auth.fiskerdps.com -REACT_APP_UPLOAD_SERVICE_URL = http://localhost:8080/api/upload \ No newline at end of file +REACT_APP_UPLOAD_SERVICE_URL = https://gw-dev.fiskerdps.com \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 52b51e3..70e7b18 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,7 +3,6 @@ FROM node:12-alpine as builder COPY package*.json ./ RUN npm install COPY . . -COPY .env.template .env RUN npm run build FROM nginx:alpine diff --git a/src/components/Contexts/FileUploadContext.jsx b/src/components/Contexts/FileUploadContext.jsx index 74739bc..f75e0af 100644 --- a/src/components/Contexts/FileUploadContext.jsx +++ b/src/components/Contexts/FileUploadContext.jsx @@ -39,7 +39,7 @@ export const FileUploadProvider = ({ children }) => { const { data } = await uploadFile(file, accessToken, setProgress, cancelUpload); if (data.message) throw new Error(`${data.error}. ${data.message}`); - const url = ((data && data.link) ? data.link : "No URL available"); + const url = ((data && data.link && data.link.link) ? data.link.link : "No URL available"); setLinkURL(url); setStatus(`Uploaded ${filename}`); setCancelUpload(null); diff --git a/src/services/__mocks__/uploadFile.js b/src/services/__mocks__/uploadFile.js index 4443a17..f501c51 100644 --- a/src/services/__mocks__/uploadFile.js +++ b/src/services/__mocks__/uploadFile.js @@ -1,6 +1,6 @@ import delay from "../../utils/delay"; -let uploadFileResponse = { data: { link: "CLOUDFRONT_URL" } }; +let uploadFileResponse = { data: { link: { link: "CLOUDFRONT_URL" } } }; let uploadFileDelay = false; let issuedCancelToken = null; diff --git a/src/services/uploadFile.js b/src/services/uploadFile.js index db1efb8..3df0f81 100644 --- a/src/services/uploadFile.js +++ b/src/services/uploadFile.js @@ -1,6 +1,6 @@ import axios from 'axios'; -const UPLOAD_ENDPOINT = process.env.REACT_APP_UPLOAD_SERVICE_URL || "http://localhost:8080"; +const UPLOAD_ENDPOINT = process.env.REACT_APP_UPLOAD_SERVICE_URL || "https://gw-dev.fiskerdps.com"; export const getCancelToken = () => { const token = axios.CancelToken;