-
-
Notifications
You must be signed in to change notification settings - Fork 882
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
Fixed: App can only be accessed on localhost #1697
Fixed: App can only be accessed on localhost #1697
Conversation
Our Pull Request Approval ProcessWe have these basic policies to make the approval process smoother for our volunteer team. Testing Your CodePlease make sure your code passes all tests. Our test code coverage system will fail if these conditions occur:
The process helps maintain the overall reliability of the code base and is a prerequisite for getting your PR approved. Assigned reviewers regularly review the PR queue and tend to focus on PRs that are passing. ReviewersDo not assign reviewers. Our Queue Monitors will review your PR and assign them.
Reviewing Your CodeYour reviewer(s) will have the following roles:
CONTRIBUTING.mdRead our CONTRIBUTING.md file. Most importantly:
Other
|
setup.ts
Outdated
message: 'Would you like to set up a remote host?', | ||
default: true, | ||
}); | ||
shouldSetRemoteHost = shouldSetRemoteHostResponse; |
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 is unnecessary, setup already asks for the
REACT_APP_TALAWA_URL
value that includes a TCP port. BTW, You cannot assume the port will never change. - You are duplicating the prompting for an existing parameter. You should be able to derive the necessary information from the
REACT_APP_TALAWA_URL
value.
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 is not asking for API endpoint, but for solving the problem.
If we are accessing the admin portal from the network and the API endpoint contains "localhost", it causes the error. So asking for the remote URL is to change the URL into a URL that can be accessed without any problem.
But if the Admin URL does not explicitly show the port, then the developer would manually have to change the api url.
|
||
render( | ||
<ApolloProvider client={client}> | ||
<Provider store={store}> |
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.
Why was this removed?
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 test was redundant and was causing problems while testing. Removing it did not have an impact on the branch and line coverage.
{ | ||
type: 'input', | ||
name: 'url', | ||
message: `Enter your remote url in the format 'http://hosturl/' (don't enter the port)`, |
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 not necessary, setup already asks for you to Enter your talawa-api endpoint
using the REACT_APP_TALAWA_URL
value.
const ans = | ||
input.includes(':') && input.indexOf(':') == input.lastIndexOf(':'); | ||
const urlRegex = /^(https?|ftp):\/\/[^\s/$.?#].[^\s]*$/; | ||
return ans && urlRegex.test(input); |
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 not necessary, setup already asks for you to Enter your talawa-api endpoint
using the REACT_APP_TALAWA_URL
value.
@palisadoes this is to fix the immediate error, the best practice would have been to give an error if the admin portal is being accessed remotely and the API endpoint contains "localhost" |
So you are saying we are fixing to problems:
This requires the different prompts in setup. This was also why you asked the question about automatically determining the value because you were referring to the non localhost Admin scenario. I didn't understand the context of the question. We need to solve for both scenarios. It would be greatly preferred to make the Admin app automatically get its Admin related information. For example some browsers could be addressing Admin on IPv4 and others on IPv6 which would make a configured value for this inappropriate. Some could be addressing the app via network address translation (NAT) which would add more unpredictability. If that's not possible, which I doubt, then the prompt needs to be clearer. It was not apparent that this was related to the Admin portal. |
@palisadoes Rethinking, I think the best approach would be to set the REACT_APP_TALAWA_URL to the remote network link instead of this workaround on the admin side. So, if the developer wants to access the portal remotely, they will set the API link for example "http://192.168.1.4:4000/graphql" instead of "http://localhost:4000/graphql", which would fix the error without needing this PR. the remote URL can be printed when the API server is started |
Not necessarily, this PR may still be valid. Please test this out. The issue was originally created because things broke when:
|
This PR did not impact this case
This PR is fixing this only case. |
Does this PR still need to be modified to a documentation only update? |
It would avoid having unnecessary additions to the code. |
Please make the documentation modifications the core of this PR |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## develop #1697 +/- ##
========================================
Coverage 97.39% 97.39%
========================================
Files 168 168
Lines 4148 4148
Branches 1206 1210 +4
========================================
Hits 4040 4040
+ Misses 105 104 -1
- Partials 3 4 +1 ☔ View full report in Codecov by Sentry. |
093fda6
into
PalisadoesFoundation:develop
What kind of change does this PR introduce?
This PR fixes the problem of the portal not being able to be accessed if not on localhost.
Issue Number:
Fixes #1244
Did you add tests for your changes?
Yes
Snapshots/Videos:
If relevant, did you update the documentation?
Yes
Summary
This issue was caused mainly by the case in which the API url contains 'localhost'.
Does this PR introduce a breaking change?
No
Other information
2 problems occurred while working on the issue.
are both fetching endpoints that do not exist and hence the addon store component also does not work.
Should I make issues for them?
Have you read the contributing guide?
Yes