diff --git a/src/app.jsx b/src/app.jsx index 16efbe2d..d31566c3 100644 --- a/src/app.jsx +++ b/src/app.jsx @@ -111,7 +111,7 @@ function App() { if (code) { console.log({ code }); // Clear the code from the URL - window.history.replaceState({}, document.title, '/'); + window.history.replaceState({}, document.title, location.pathname || '/'); const clientID = store.session.get('clientID'); const clientSecret = store.session.get('clientSecret'); diff --git a/src/pages/accounts.jsx b/src/pages/accounts.jsx index c7910b5a..47d90b01 100644 --- a/src/pages/accounts.jsx +++ b/src/pages/accounts.jsx @@ -143,7 +143,7 @@ function Accounts({ onClose }) { accounts.splice(i, 1); store.local.setJSON('accounts', accounts); // location.reload(); - location.href = '/'; + location.href = location.pathname || '/'; }} > diff --git a/src/utils/auth.js b/src/utils/auth.js index 36898f7a..600b0c0c 100644 --- a/src/utils/auth.js +++ b/src/utils/auth.js @@ -4,8 +4,8 @@ const { VITE_CLIENT_NAME: CLIENT_NAME, VITE_WEBSITE: WEBSITE } = import.meta export async function registerApplication({ instanceURL }) { const registrationParams = new URLSearchParams({ client_name: CLIENT_NAME, - redirect_uris: location.origin, scopes: 'read write follow', + redirect_uris: location.origin + location.pathname, website: WEBSITE, }); const registrationResponse = await fetch( @@ -27,7 +27,7 @@ export async function getAuthorizationURL({ instanceURL, client_id }) { const authorizationParams = new URLSearchParams({ client_id, scope: 'read write follow', - redirect_uri: location.origin, + redirect_uri: location.origin + location.pathname, // redirect_uri: 'urn:ietf:wg:oauth:2.0:oob', response_type: 'code', }); @@ -44,7 +44,7 @@ export async function getAccessToken({ const params = new URLSearchParams({ client_id, client_secret, - redirect_uri: location.origin, + redirect_uri: location.origin + location.pathname, grant_type: 'authorization_code', code, scope: 'read write follow', diff --git a/vite.config.js b/vite.config.js index 4eaec943..0cf8a335 100644 --- a/vite.config.js +++ b/vite.config.js @@ -25,6 +25,7 @@ const rollbarCode = fs.readFileSync( // https://vitejs.dev/config/ export default defineConfig({ + base: './', mode: NODE_ENV, define: { __BUILD_TIME__: JSON.stringify(now),