From dcbc0c9ed77b131e207265df9f3d541d96a48ff4 Mon Sep 17 00:00:00 2001 From: Maya Treacy Date: Sun, 27 Jun 2021 20:28:56 +1000 Subject: [PATCH] Dev: Add BIT backend heroku url add heroku specific branch on fork repo Refactor homepage url to fork repo for test remove extra backslash add CORS ORIGIN for remote BIT web on Login Add CORS ORIGIN headers on other existing features refactor to staging remote urls remove travis yml refactor config to include both upstream and fork BIT web url revert dotenv since gh action use different method for secret refactor config update config --- .github/workflows/deploy.yml | 6 +++--- .travis.yml | 8 -------- src/config.js | 7 ++++++- src/login/Login.jsx | 4 +++- src/members/Members.jsx | 3 ++- src/myorganization/EditOrganization.jsx | 4 +++- src/myorganization/EditProgram.jsx | 3 ++- src/myorganization/EditPrograms.jsx | 3 ++- src/myspace/AdditionalInfo.jsx | 4 +++- src/myspace/PersonalBackground.jsx | 4 +++- src/myspace/PersonalDetails.jsx | 4 +++- src/organizations/Organizations.jsx | 3 ++- src/organizations/Programs.jsx | 3 ++- src/register/Register.jsx | 3 ++- 14 files changed, 36 insertions(+), 23 deletions(-) delete mode 100644 .travis.yml diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 4573cf2e..0b2250ec 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -1,11 +1,11 @@ # Basic workflow for Actions name: Build and Deploy to GitHub static pages -# Controls when the action will run. +# Controls when the action will run. on: # Triggers the workflow on push or pull request events but only for the develop branch push: - branches: [ develop ] + branches: [ develop, bit-heroku-url ] # Allows you to run this workflow manually from the Actions tab workflow_dispatch: @@ -30,7 +30,7 @@ jobs: run: | npm install npm run build - + - name: Deploy to Github Pages uses: JamesIves/github-pages-deploy-action@3.7.1 with: diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 8c8ff7f1..00000000 --- a/.travis.yml +++ /dev/null @@ -1,8 +0,0 @@ -language: node_js -node_js: - - 12.16 -cache: - npm: false -script: - - npm test - - CI=false npm run build diff --git a/src/config.js b/src/config.js index 1691a237..ff91e719 100644 --- a/src/config.js +++ b/src/config.js @@ -1 +1,6 @@ -export const BASE_API = process.env.REACT_APP_BASE_API ? process.env.REACT_APP_BASE_API : "http://localhost:5000" +// export const BASE_API = process.env.REACT_APP_BASE_API ? process.env.REACT_APP_BASE_API : "http://localhost:5000" +export const BASE_API = process.env.REACT_APP_BASE_API ? process.env.REACT_APP_BASE_API : "https://bridge-in-tech-backend.herokuapp.com/" +// export const CORS_ORIGIN = process.env.REACT_APP_CORS_ORIGIN ? process.env.REACT_APP_CORS_ORIGIN : "https://anitab-org.github.io" +export const CORS_ORIGIN = process.env.REACT_APP_CORS_ORIGIN ? process.env.REACT_APP_CORS_ORIGIN : "https://mtreacy002.github.io" +// export const CORS_ORIGIN = process.env.REACT_APP_CORS_ORIGIN ? process.env.REACT_APP_CORS_ORIGIN : "http://localhost:3000" + diff --git a/src/login/Login.jsx b/src/login/Login.jsx index c74f436b..e4700e7e 100644 --- a/src/login/Login.jsx +++ b/src/login/Login.jsx @@ -2,7 +2,7 @@ import React, { useState, useContext } from "react"; import "./Login.css"; import { Redirect, Link } from "react-router-dom"; import { AuthContext } from "../AuthContext"; -import {BASE_API} from "../config"; +import {BASE_API, CORS_ORIGIN} from "../config"; import { SERVICE_UNAVAILABLE_ERROR } from "../messages"; export default function Login() { @@ -23,6 +23,7 @@ export default function Login() { headers: { "Accept": "application/json", "Content-Type": "application/json", + "Access-Control-Allow-Origin": {CORS_ORIGIN} }, body: JSON.stringify(payload) }; @@ -37,6 +38,7 @@ export default function Login() { "Authorization": `Bearer ${access_token}`, "Accept": "application/json", "Content-Type": "application/json", + "Access-Control-Allow-Origin": {CORS_ORIGIN} } }).then(async response => { let userData = await response.json(); diff --git a/src/members/Members.jsx b/src/members/Members.jsx index 7e3830a9..dedab1bb 100644 --- a/src/members/Members.jsx +++ b/src/members/Members.jsx @@ -2,7 +2,7 @@ import React, { useState, useContext, useEffect } from "react"; import { Table } from "react-bootstrap"; import { Link } from "react-router-dom"; import { AuthContext } from "../AuthContext"; -import { BASE_API } from "../config"; +import { BASE_API, CORS_ORIGIN } from "../config"; import { SERVICE_UNAVAILABLE_ERROR } from "../messages"; import "./Member.css"; @@ -19,6 +19,7 @@ export default function Members() { "Authorization": `Bearer ${access_token}`, "Accept": "application/json", "Content-Type": "application/json", + "Access-Control-Allow-Origin": {CORS_ORIGIN} }, }; diff --git a/src/myorganization/EditOrganization.jsx b/src/myorganization/EditOrganization.jsx index ce0265cd..69917f7a 100644 --- a/src/myorganization/EditOrganization.jsx +++ b/src/myorganization/EditOrganization.jsx @@ -1,7 +1,7 @@ import React, {useState, useEffect, useContext} from "react"; import { Link } from "react-router-dom"; import {AuthContext} from "../AuthContext"; -import {BASE_API} from "../config"; +import {BASE_API, CORS_ORIGIN} from "../config"; import "./EditOrganization.css"; import {SERVICE_UNAVAILABLE_ERROR} from "../messages"; import { ORGANIZATION_STATUS} from "../enums"; @@ -22,6 +22,7 @@ export default function EditOrganization() { "Authorization": `Bearer ${access_token}`, "Accept": "application/json", "Content-Type": "application/json", + "Access-Control-Allow-Origin": {CORS_ORIGIN} }, }; @@ -53,6 +54,7 @@ export default function EditOrganization() { "Authorization": `Bearer ${access_token}`, "Accept": "application/json", "Content-Type": "application/json", + "Access-Control-Allow-Origin": {CORS_ORIGIN} }, body: JSON.stringify(payload) }; diff --git a/src/myorganization/EditProgram.jsx b/src/myorganization/EditProgram.jsx index 444f6dba..360a36cc 100644 --- a/src/myorganization/EditProgram.jsx +++ b/src/myorganization/EditProgram.jsx @@ -12,7 +12,7 @@ import { HIGHEST_EDUCATION, YEARS_OF_EXPERIENCE } from "../backgrounds"; -import { BASE_API } from "../config"; +import { BASE_API, CORS_ORIGIN } from "../config"; import { SERVICE_UNAVAILABLE_ERROR } from "../messages"; import { PROGRAM_STATUS, CONTACT_TYPE, ZONE } from "../enums"; import { AuthContext } from "../AuthContext"; @@ -66,6 +66,7 @@ export default function EditProgram() { "Authorization": `Bearer ${access_token}`, "Accept": "application/json", "Content-Type": "application/json", + "Access-Control-Allow-Origin": {CORS_ORIGIN} }, body: JSON.stringify(payload) }; diff --git a/src/myorganization/EditPrograms.jsx b/src/myorganization/EditPrograms.jsx index 0eb2ef29..78dfeb96 100644 --- a/src/myorganization/EditPrograms.jsx +++ b/src/myorganization/EditPrograms.jsx @@ -2,7 +2,7 @@ import React, { useState, useEffect, useContext } from "react"; import { Table } from "react-bootstrap"; import { Link, useLocation } from "react-router-dom"; import { AuthContext } from "../AuthContext"; -import { BASE_API } from "../config"; +import { BASE_API, CORS_ORIGIN } from "../config"; import "./EditOrganization.css"; import { SERVICE_UNAVAILABLE_ERROR } from "../messages"; @@ -22,6 +22,7 @@ export default function EditPrograms() { "Authorization": `Bearer ${access_token}`, "Accept": "application/json", "Content-Type": "application/json", + "Access-Control-Allow-Origin": {CORS_ORIGIN} }, }; diff --git a/src/myspace/AdditionalInfo.jsx b/src/myspace/AdditionalInfo.jsx index 06974de5..c1aec809 100644 --- a/src/myspace/AdditionalInfo.jsx +++ b/src/myspace/AdditionalInfo.jsx @@ -1,5 +1,5 @@ import React, { useState, useEffect, useContext } from "react"; -import { BASE_API } from "../config"; +import { BASE_API, CORS_ORIGIN } from "../config"; import { AuthContext } from "../AuthContext"; import "./MySpace.css"; import { SERVICE_UNAVAILABLE_ERROR } from "../messages"; @@ -21,6 +21,7 @@ export default function AdditionalInfo() { "Authorization": `Bearer ${access_token}`, "Accept": "application/json", "Content-Type": "application/json", + "Access-Control-Allow-Origin": {CORS_ORIGIN} }, }; @@ -59,6 +60,7 @@ export default function AdditionalInfo() { "Authorization": `Bearer ${access_token}`, "Accept": "application/json", "Content-Type": "application/json", + "Access-Control-Allow-Origin": {CORS_ORIGIN} }, body: JSON.stringify(payload) }; diff --git a/src/myspace/PersonalBackground.jsx b/src/myspace/PersonalBackground.jsx index 1aec87a0..af68100a 100644 --- a/src/myspace/PersonalBackground.jsx +++ b/src/myspace/PersonalBackground.jsx @@ -1,5 +1,5 @@ import React, { useState, useEffect, useContext } from "react"; -import { BASE_API } from "../config"; +import { BASE_API, CORS_ORIGIN } from "../config"; import { AuthContext } from "../AuthContext"; import "./MySpace.css"; import { SERVICE_UNAVAILABLE_ERROR } from "../messages"; @@ -28,6 +28,7 @@ export default function PersonalBackground() { "Authorization": `Bearer ${access_token}`, "Accept": "application/json", "Content-Type": "application/json", + "Access-Control-Allow-Origin": {CORS_ORIGIN} }, }; @@ -64,6 +65,7 @@ export default function PersonalBackground() { "Authorization": `Bearer ${access_token}`, "Accept": "application/json", "Content-Type": "application/json", + "Access-Control-Allow-Origin": {CORS_ORIGIN} }, body: JSON.stringify(payload) }; diff --git a/src/myspace/PersonalDetails.jsx b/src/myspace/PersonalDetails.jsx index 2b17398c..0efdc63b 100644 --- a/src/myspace/PersonalDetails.jsx +++ b/src/myspace/PersonalDetails.jsx @@ -1,6 +1,6 @@ import React, { useState, useEffect, useContext } from "react"; import { AuthContext } from "../AuthContext"; -import { BASE_API } from "../config"; +import { BASE_API, CORS_ORIGIN } from "../config"; import "./MySpace.css"; import { SERVICE_UNAVAILABLE_ERROR } from "../messages"; @@ -22,6 +22,7 @@ export default function PersonalDetails() { "Authorization": `Bearer ${access_token}`, "Accept": "application/json", "Content-Type": "application/json", + "Access-Control-Allow-Origin": {CORS_ORIGIN} }, }; @@ -57,6 +58,7 @@ export default function PersonalDetails() { "Authorization": `Bearer ${access_token}`, "Accept": "application/json", "Content-Type": "application/json", + "Access-Control-Allow-Origin": {CORS_ORIGIN} }, body: JSON.stringify(payload) }; diff --git a/src/organizations/Organizations.jsx b/src/organizations/Organizations.jsx index 4487e77e..c2b25b25 100644 --- a/src/organizations/Organizations.jsx +++ b/src/organizations/Organizations.jsx @@ -2,7 +2,7 @@ import React, { useState, useContext, useEffect } from "react"; import { Table } from "react-bootstrap"; import { Link } from "react-router-dom"; import { AuthContext } from "../AuthContext"; -import { BASE_API } from "../config"; +import { BASE_API, CORS_ORIGIN } from "../config"; import { SERVICE_UNAVAILABLE_ERROR } from "../messages"; import "./Organization.css"; @@ -19,6 +19,7 @@ export default function Organizations() { "Authorization": `Bearer ${access_token}`, "Accept": "application/json", "Content-Type": "application/json", + "Access-Control-Allow-Origin": {CORS_ORIGIN} }, }; diff --git a/src/organizations/Programs.jsx b/src/organizations/Programs.jsx index 1dea2a4b..44e0719e 100644 --- a/src/organizations/Programs.jsx +++ b/src/organizations/Programs.jsx @@ -2,7 +2,7 @@ import React, { useEffect, useState, useContext} from "react"; import { Table } from "react-bootstrap"; import { Link, useLocation } from "react-router-dom"; import { AuthContext } from "../AuthContext"; -import { BASE_API } from "../config"; +import { BASE_API, CORS_ORIGIN } from "../config"; import { SERVICE_UNAVAILABLE_ERROR } from "../messages"; @@ -21,6 +21,7 @@ export default function Programs() { "Authorization": `Bearer ${access_token}`, "Accept": "application/json", "Content-Type": "application/json", + "Access-Control-Allow-Origin": {CORS_ORIGIN} }, }; diff --git a/src/register/Register.jsx b/src/register/Register.jsx index 36113c76..8bc50bfd 100644 --- a/src/register/Register.jsx +++ b/src/register/Register.jsx @@ -2,7 +2,7 @@ import React, { useState, useContext } from "react"; import "./Register.css"; import { Redirect, Link } from "react-router-dom"; import { AuthContext } from "../AuthContext"; -import {BASE_API} from "../config"; +import {BASE_API, CORS_ORIGIN} from "../config"; import {SERVICE_UNAVAILABLE_ERROR} from "../messages"; import TermsAndPrivacyPolicyModal from "./TermsAndPrivacyPolicyModal"; @@ -36,6 +36,7 @@ export default function Register() { headers: { "Accept": "application/json", "Content-Type": "application/json", + "Access-Control-Allow-Origin": {CORS_ORIGIN} }, body: JSON.stringify(payload) };