-
Notifications
You must be signed in to change notification settings - Fork 28
Uses relative paths for urls #299
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
Conversation
|
Analogously to bblfsh/web#185 I haven't tested this by running gitbase-web behind a Kubernetes proxy as written in issue #286, but for simplicity I've used nginx (I suppose that it should be the same) with the following configuration: where gitbase-web was running on port With this setup gitbase-web works correctly both by using it directly through I wasn't able to make it work without the routing rule in nginx for the |
frontend/src/api.js
Outdated
| const selectLimit = envVars.SELECT_LIMIT; | ||
|
|
||
| const apiUrl = url => `${serverUrl}${url}`; | ||
| // ensure to use relative urls in order to work behind proxies |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This part is tricky, so I would expand more this comment. Something like:
If serverUrl is unset, this replaces the leading / in order to work behind proxies with a path other than /.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's apply this comment (or a better one if you see a way to explain it more clearly)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh yes sorry, complete forgot about that!
|
The css path problem might be caused by the fact that we are using |
|
I've done a quick test and the fonts use the right path if we move the |
|
@carlosms thanks a lot for testing it! Is it ok then to move the fonts and close the issues with this fix? |
|
Yes, let's move the fonts also in this PR. |
|
BTW thank you for providing the configuration needed for testing @se7entyse7en. Here is how I'm testing it, with some more details to be ready to c&p. File nginx.conf, contains the defaults + @se7entyse7en's conf: Run nginx docker container: Now http://localhost:8081/gitbase/ is a gateway to http://localhost:8080, so you can run |
|
@carlosms after moving the fonts and changed But I noticed that the font file doesn't exist actually. If I remove that font from the less file then the build works. And everything works. |
|
Please review the original commit (see #158) to see if that file should be there and it was forgotten, or if the problem is that we have that extra include when we should not. |
596a65a to
b8fc8d1
Compare
|
@carlosms it turned out that there was a missing font. Thanks for pointing to the issue. 👍 |
carlosms
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A couple of suggestions
frontend/src/api.js
Outdated
| const selectLimit = envVars.SELECT_LIMIT; | ||
|
|
||
| const apiUrl = url => `${serverUrl}${url}`; | ||
| // ensure to use relative urls in order to work behind proxies |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's apply this comment (or a better one if you see a way to explain it more clearly)
frontend/src/fonts.less
Outdated
|
|
||
| /*! | ||
| * Source Sans Pro typeface https://fonts.google.com/specimen/Source+Sans+Pro | ||
| * Source Sans Pro typeface https:/./fonts.google.com/specimen/Source+Sans+Pro |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Replace-all? 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤦♂️
b8fc8d1 to
9a58835
Compare
|
Given that the diff is small I already squashed the commits addressing your comments. |
frontend/src/api.js
Outdated
| url.searchParams.append('query', sql); | ||
| return url.toString(); | ||
| const rawUrl = apiUrl('/export'); | ||
| const href = new URL(window.location.href); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I meant to include this in the previous review.
Instead of using window.location and then discard it, please check if we can do this:
const params = new URLSearchParams();
params.append('query', sql);
return `${rawUrl}?${params.toString()}`;There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It works! And it's much more cleaner this way 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now I see in travis the tests fail because URLSearchParams is not available in node 🤔
Maybe you can find a polyfill lib and initialize it for the node tests in setupTests.js
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup I saw that jest doesn't support URLSearchParams until version 22, and that version comes with react-scripts>=2.0.0.
Signed-off-by: Lou Marvin Caraig <loumarvincaraig@gmail.com>
Signed-off-by: Lou Marvin Caraig <loumarvincaraig@gmail.com>
Signed-off-by: Lou Marvin Caraig <loumarvincaraig@gmail.com>
9a58835 to
5f47941
Compare
frontend/package.json
Outdated
| "react-app-rewire-svg-react-loader": "codebandits/react-app-rewire-svg-react-loader", | ||
| "react-app-rewired": "^1.5.2", | ||
| "react-test-renderer": "^16.4.0", | ||
| "url-search-params": "^1.1.0", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Apparently this package has been deprecated and the author recommends to use @ungap/url-search-params instead
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My bad, I haven't noticed it.
Signed-off-by: Lou Marvin Caraig <loumarvincaraig@gmail.com>
f991d07 to
ddfd019
Compare
carlosms
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👏 👏 👏
Closes #286 as it makes gitbase-web work both directly and behind a proxy with path other than /.