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

Use relative paths for API #811

Merged
merged 64 commits into from
Jul 22, 2022
Merged

Conversation

adamlerer
Copy link
Contributor

Hi @kestasjk . With the 0.3 release, the beta UI isn't working in prod, due to using env-specified paths for the backend that weren't set to webdiplomacy.net when we compiled.

We're discussing on our end what's the best way to do this in the future. For the moment can you see if switching back to relative paths fixes the issue?

cc @utiq

adamlerer and others added 30 commits June 14, 2022 10:38
Add phase names between messages
Don't broadcast a private message to everyone just because you are mod
* html sanitize fix

* fix lint errors

Co-authored-by: utiq <cesargutierrez@fb.com>
Don't give an exception if vote response is empty string (ie no votes)
WDIP-32: Turn off early access guard for beta
WDIP-21: Fix handling of Civil Disorder in beta UI
* docker-compose configuration

* put back temp change

* put back proxy in package.json

* port back to 8895

* Revert "port back to 8895"

This reverts commit a793f6a.

* Revert "put back proxy in package.json"

This reverts commit 091637c.

* add scripts to run development env out of the box

* fix entrypoint

* fix entrypoint

* fix permissions

* add config copy

* update variable

* update default values

Co-authored-by: utiq <cesargutierrez@fb.com>
WDIP-17: Different phase duration for retreats/builds/missed turns
…macy"

This reverts commit 327f288, reversing
changes made to f43b00e.
@kestasjk
Copy link
Owner

kestasjk commented Jul 8, 2022

Hi @adamlerer ,

Is it definitely not working at the moment? It seems to be working here after I added the undefined folder workaround.

I thought perhaps it was somehow detecting when I went into Web Developer tools to view the page, since it was working fine for me long after we committed but then suddenly stopped. In the error logs there were only three IPs I could see that have this issue:
image

FYI users can use www.webdiplomacy.net or webdiplomacy.net , and could have authentication errors if it has the domain encoded in.

Just want to be a bit clearer on what's going wrong before applying this. I would have thought that we would get heaps of error reports and that the error logs would be full if the issue is that all requests were going to the wrong place. Was there a reason for switching to using the environment variable or was that just for dev purposes?

Rgds,
Chris

@utiq
Copy link
Contributor

utiq commented Jul 9, 2022

Hello guys. I wouldn't suggest to go back to relative path because is going to break everything on dev environment. Also, it's not a good practice to use relative paths in production.

The fix is easy, it is just to add the production env variables when the app is built. Let me do that in the morning. Which branch should I use? This is happening in the master branch?

@adamlerer
Copy link
Contributor Author

What is the "undefined folder workaround"? It has indeed started working for me when I tried it now. If it's working lets leave it alone until we can discuss the tradeoffs.

The source of the issue is that I ran npm run build without setting REACT_APP_WD_BASE_URL=https://webdiplomacy.net in my .env.X file, so this var was undefined and it was trying to access the backend through the path undefined/api.php instead of https://webdiplomacy.net/api.php.

We've gone back and forth between the env var and relative paths... I prefer relative paths because if you use env vars, then they need to be configured differently for dev (localhost) vs prod (https://webdiplomacy.net) vs other people hosting the site, and these hardcoded paths get checked in to the hardcoded js files in /beta and can't really be tested until you run in prod where you can hit that backend.

However @utiq and others have told me that relative urls are bad practice, which is probably true, but I haven't figured out why. P.S. @utiq I tried the dev environment with the relative paths and it seemed to work for me?

@utiq
Copy link
Contributor

utiq commented Jul 9, 2022

@kestasjk I cannot create a PR, can you add me as a collaborator so I can push the changes?

@kestasjk
Copy link
Owner

kestasjk commented Jul 11, 2022 via email

@kestasjk
Copy link
Owner

kestasjk commented Jul 11, 2022 via email

@utiq
Copy link
Contributor

utiq commented Jul 11, 2022

@kestasjk I wasn't trying to push code directly, I always create PRs. The problem is that I wasn't able to create remote branches in the repo, so I wasn't able to create a PR. How can we solve that?

@adamlerer adamlerer changed the base branch from master to staging July 12, 2022 04:23
@adamlerer
Copy link
Contributor Author

Discussed with @utiq and we concluded that relative paths are the better option for this setup.

I've switched the PR to merge to staging for testing.

@kestasjk
Copy link
Owner

kestasjk commented Jul 13, 2022 via email

@kestasjk kestasjk merged commit 7ca7802 into kestasjk:staging Jul 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants