From 70cbe9eaab11e900fcf55aa6843edbd231bfd572 Mon Sep 17 00:00:00 2001 From: Wille Marcel Date: Mon, 26 Aug 2024 10:48:09 -0300 Subject: [PATCH 1/2] Fix DEV stack authentication url with localhost redirect_uri --- package.json | 10 ++-------- src/views/navbar_sidebar.js | 6 +++++- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/package.json b/package.json index 065d1fbf..dd1f4b04 100644 --- a/package.json +++ b/package.json @@ -70,18 +70,12 @@ "scripts": { "precommit": "lint-staged", "flow": "flow", - "start": "react-scripts start", + "start": "REACT_APP_STACK=DEV react-scripts start", "lint": "eslint src", "test": "npm run lint && react-scripts test --env=jsdom", "coverage": "react-scripts test --env=jsdom --coverage", "build": "REACT_APP_VERSION=\"$(node -e \"console.log(require('./package.json').version)\")\" REACT_APP_STACK=DEV react-scripts build", - "build:dev": "REACT_APP_VERSION=\"$(node -e \"console.log(require('./package.json').version)\")\" REACT_APP_STACK=DEV PUBLIC_URL=https://mapbox.github.io/osmcha-frontend react-scripts build", - "deploy:dev": "gh-pages -d build", - "build:staging": "REACT_APP_VERSION=\"$(node -e \"console.log(require('./package.json').version)\")\" REACT_APP_STACK=STAGING PUBLIC_URL=https://staging.osmcha.org react-scripts build", - "deploy:staging": "gh-pages -d build -b oh-pages", - "build:prod": "REACT_APP_VERSION=\"$(node -e \"console.log(require('./package.json').version)\")\" REACT_APP_STACK=PRODUCTION PUBLIC_URL=https://osmcha.org react-scripts build", - "deploy:prod": "gh-pages -d build -b oh-pages", - "build:test": "REACT_APP_VERSION=\"$(node -e \"console.log(require('./package.json').version)\")\" REACT_APP_STACK=PRODUCTION PUBLIC_URL=https://osmcha-test.ds.io react-scripts build" + "build:prod": "REACT_APP_VERSION=\"$(node -e \"console.log(require('./package.json').version)\")\" REACT_APP_STACK=PRODUCTION PUBLIC_URL=https://osmcha.org react-scripts build" }, "lint-staged": { "*.js": [ diff --git a/src/views/navbar_sidebar.js b/src/views/navbar_sidebar.js index 7a7278f3..64af2a68 100644 --- a/src/views/navbar_sidebar.js +++ b/src/views/navbar_sidebar.js @@ -34,7 +34,11 @@ class NavbarSidebar extends React.PureComponent { handleLoginClick = () => { getAuthUrl().then(res => { - window.location.assign(res.auth_url); + const authUrl = new URL(res.auth_url); + if (process.env.REACT_APP_STACK === 'DEV') { + authUrl.searchParams.set('redirect_uri', 'http://localhost:3000'); + } + window.location.assign(authUrl.href); }); }; From d0d948a9100566832bcf9a9fc59ba9b70656b317 Mon Sep 17 00:00:00 2001 From: Wille Marcel Date: Mon, 26 Aug 2024 12:00:21 -0300 Subject: [PATCH 2/2] Fix URL --- src/views/navbar_sidebar.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/views/navbar_sidebar.js b/src/views/navbar_sidebar.js index 64af2a68..94b1f107 100644 --- a/src/views/navbar_sidebar.js +++ b/src/views/navbar_sidebar.js @@ -36,7 +36,10 @@ class NavbarSidebar extends React.PureComponent { getAuthUrl().then(res => { const authUrl = new URL(res.auth_url); if (process.env.REACT_APP_STACK === 'DEV') { - authUrl.searchParams.set('redirect_uri', 'http://localhost:3000'); + authUrl.searchParams.set( + 'redirect_uri', + 'http://127.0.0.1:3000/authorized' + ); } window.location.assign(authUrl.href); });