Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable hosting from subdirectory #771

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"engines": {
"node": "^12.13.1"
},
"homepage": "",
"dependencies": {
"@bity/oauth2-auth-code-pkce": "^2.13.0",
"bowser": "^2.11.0",
Expand Down
4 changes: 3 additions & 1 deletion src/App.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* global process */

import React, { PureComponent } from 'react';
import { Provider } from 'react-redux';
import Store from './store';
Expand Down Expand Up @@ -216,7 +218,7 @@ export default class App extends PureComponent {
render() {
return (
<DragDropContext onDragEnd={this.handleDragEnd}>
<Router>
<Router basename={process.env.PUBLIC_URL}>
<Provider store={this.store}>
<div className="App">
<Entry />
Expand Down
12 changes: 7 additions & 5 deletions src/components/SyncServiceSignIn/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ function WebDAVForm() {
persistField('webdavEndpoint', url);
persistField('webdavUsername', username);
persistField('webdavPassword', password);
window.location = window.location.origin + '/';
window.location = window.location.origin + process.env.PUBLIC_URL;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How does it behave if PUBLIC_URL is undefined instead of /?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, good catch, thanks. It just turns into "" so the trailing slash would be missing. It looks like trailing slashes are removed from the PUBLIC_URL anyway (for both the homepage method and directly specifying PUBLIC_URL) so I'll simply re-add the + '/' after the PUBLIC_URL.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alright, but does it also work for export PUBLIC_URL='/' (which should be allowed IMO)? Sorry for that annoyance; I also don't have a solution by hand right now...

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes I also tested that, this behaves the same as the other cases i.e. the slash is removed and PUBLIC_URL ends up as "" which is what we want.

}}
>
<p>
Expand Down Expand Up @@ -165,9 +165,11 @@ export default class SyncServiceSignIn extends PureComponent {
clientId: process.env.REACT_APP_DROPBOX_CLIENT_ID,
fetch: fetch.bind(window),
});
dropbox.auth.getAuthenticationUrl(window.location.origin + '/').then((authURL) => {
window.location = authURL;
});
dropbox.auth
.getAuthenticationUrl(window.location.origin + process.env.PUBLIC_URL)
.then((authURL) => {
window.location = authURL;
});
}

handleGoogleDriveClick() {
Expand All @@ -185,7 +187,7 @@ export default class SyncServiceSignIn extends PureComponent {

gapi.auth2.getAuthInstance().signIn({
ux_mode: 'redirect',
redirect_uri: window.location.origin,
redirect_uri: window.location.origin + process.env.PUBLIC_URL,
});
});
});
Expand Down
2 changes: 1 addition & 1 deletion src/sync_backend_clients/gitlab_sync_backend_client.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export const createGitlabOAuth = () => {
authorizationUrl: 'https://gitlab.com/oauth/authorize',
tokenUrl: 'https://gitlab.com/oauth/token',
clientId: process.env.REACT_APP_GITLAB_CLIENT_ID,
redirectUrl: window.location.origin,
redirectUrl: window.location.origin + process.env.PUBLIC_URL,
scopes: ['api'],
extraAuthorizationParams: {
clientSecret: process.env.REACT_APP_GITLAB_SECRET,
Expand Down