From ea62a55f756122e3cf541cfe43dcc77e18227906 Mon Sep 17 00:00:00 2001
From: Henry Jameson <me@hjkos.com>
Date: Wed, 13 Mar 2019 19:00:04 +0200
Subject: [PATCH] fix login

---
 config/index.js               | 5 +++++
 src/services/new_api/oauth.js | 8 ++++----
 2 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/config/index.js b/config/index.js
index 56fa594057..991ace697b 100644
--- a/config/index.js
+++ b/config/index.js
@@ -38,6 +38,11 @@ module.exports = {
         changeOrigin: true,
         cookieDomainRewrite: 'localhost'
       },
+      '/oauth': {
+        target,
+        changeOrigin: true,
+        cookieDomainRewrite: 'localhost'
+      },
       '/nodeinfo': {
         target,
         changeOrigin: true,
diff --git a/src/services/new_api/oauth.js b/src/services/new_api/oauth.js
index 9e65650711..b435b82b4e 100644
--- a/src/services/new_api/oauth.js
+++ b/src/services/new_api/oauth.js
@@ -1,7 +1,7 @@
 import {reduce} from 'lodash'
 
 const getOrCreateApp = ({oauth, instance}) => {
-  const url = `${instance}/api/v1/apps`
+  const url = `/api/v1/apps`
   const form = new window.FormData()
 
   form.append('client_name', `PleromaFE_${Math.random()}`)
@@ -34,14 +34,14 @@ const login = (args) => {
     }, false)
 
     // Do the redirect...
-    const url = `${args.instance}/oauth/authorize?${dataString}`
+    const url = `/oauth/authorize?${dataString}`
 
     window.location.href = url
   })
 }
 
 const getTokenWithCredentials = ({app, instance, username, password}) => {
-  const url = `${instance}/oauth/token`
+  const url = `/oauth/token`
   const form = new window.FormData()
 
   form.append('client_id', app.client_id)
@@ -64,7 +64,7 @@ const getToken = ({app, instance, code}) => {
   form.append('client_secret', app.client_secret)
   form.append('grant_type', 'authorization_code')
   form.append('code', code)
-  form.append('redirect_uri', `${window.location.origin}/oauth-callback`)
+  form.append('redirect_uri', `/oauth-callback`)
 
   return window.fetch(url, {
     method: 'POST',
-- 
GitLab