[GH-ISSUE #56] Cannot use localhost as base url #19

Closed
opened 2026-03-16 12:48:03 +03:00 by kerem · 10 comments
Owner

Originally created by @profran on GitHub (Aug 25, 2019).
Original GitHub issue: https://github.com/hoppscotch/hoppscotch/issues/56

Describe the bug
Unable to use 'localhost' as base url.

To Reproduce
Steps to reproduce the behavior:

  1. Go to https://liyasthomas.github.io/postwoman/
  2. Click on URL field
  3. Type in: http://localhost:3002 (any port will do, I just happen to have a Node.js server running on that port)
  4. Send button is disabled

Expected behavior
I expect the Send button to be enabled

Desktop (please complete the following information):

  • OS: Arch Linux (64-bit)
  • Browser: Chromium
  • Version: 75.0.3770.142 (Official Build)

Additional context
I cloned the repo and I think the issue is related to pages/index.vue line 247 on urlNotValid's validation pattern, I changed the return statement to always be false, and the problem was solved.

Originally created by @profran on GitHub (Aug 25, 2019). Original GitHub issue: https://github.com/hoppscotch/hoppscotch/issues/56 **Describe the bug** Unable to use 'localhost' as base url. **To Reproduce** Steps to reproduce the behavior: 1. Go to https://liyasthomas.github.io/postwoman/ 2. Click on URL field 3. Type in: http://localhost:3002 (any port will do, I just happen to have a Node.js server running on that port) 4. Send button is disabled **Expected behavior** I expect the Send button to be enabled **Desktop (please complete the following information):** - OS: Arch Linux (64-bit) - Browser: Chromium - Version: 75.0.3770.142 (Official Build) **Additional context** I cloned the repo and I think the issue is related to pages/index.vue line 247 on urlNotValid's validation pattern, I changed the return statement to always be false, and the problem was solved.
kerem 2026-03-16 12:48:03 +03:00
Author
Owner

@liyasthomas commented on GitHub (Aug 25, 2019):

This might be a possibile duplicate of #2
Its a restriction due to the CORS (Cross Origin Request Policy), there isn't a client side work around to this unless the host your trying to access should respond with the appropriate CORS headers.
Please refer to docs here: https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS
Quick solution is to use a HTTPS API host, which supports CORS

<!-- gh-comment-id:524591095 --> @liyasthomas commented on GitHub (Aug 25, 2019): This might be a possibile duplicate of #2 Its a restriction due to the CORS (Cross Origin Request Policy), there isn't a client side work around to this unless the host your trying to access should respond with the appropriate CORS headers. Please refer to docs here: https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS Quick solution is to use a HTTPS API host, which supports CORS
Author
Owner

@profran commented on GitHub (Aug 25, 2019):

I first thought of that, but my Node.js API is configured to support CORS requests. I'm sure it's just the URL validation's pattern which expects an URL with a domain at the end (any_url + .com .co .ar .jp ...). I'll see if I can open a PR to solve the problem tomorrow.

<!-- gh-comment-id:524591457 --> @profran commented on GitHub (Aug 25, 2019): I first thought of that, but my Node.js API is configured to support CORS requests. I'm sure it's just the URL validation's pattern which expects an URL with a domain at the end (any_url + .com .co .ar .jp ...). I'll see if I can open a PR to solve the problem tomorrow.
Author
Owner

@liyasthomas commented on GitHub (Aug 25, 2019):

If that's the case, I'll surely look into it. You're welcomed to open a PR to fix it.

<!-- gh-comment-id:524591525 --> @liyasthomas commented on GitHub (Aug 25, 2019): If that's the case, I'll surely look into it. You're welcomed to open a PR to fix it.
Author
Owner

@NBTX commented on GitHub (Aug 25, 2019):

Ah yes, I know the issue, I had to mess with the regex to get websockets to work. I'll see if I can find some more permissive ones - and I'll add in IP addresses.

<!-- gh-comment-id:524592454 --> @NBTX commented on GitHub (Aug 25, 2019): Ah yes, I know the issue, I had to mess with the regex to get websockets to work. I'll see if I can find some more permissive ones - and I'll add in IP addresses.
Author
Owner

@liyasthomas commented on GitHub (Aug 25, 2019):

You could've opted to use two regex for URLValidation() 🤭

<!-- gh-comment-id:524592565 --> @liyasthomas commented on GitHub (Aug 25, 2019): You could've opted to use two regex for URLValidation() 🤭
Author
Owner

@NBTX commented on GitHub (Aug 25, 2019):

Yes, that was probably how I'd do it.

That said - is validation even necessary? Perhaps it would be ideal to just show an error if it fails to connect, like the websockets do, then to handle each edge case in regexes?

<!-- gh-comment-id:524592764 --> @NBTX commented on GitHub (Aug 25, 2019): Yes, that was probably how I'd do it. That said - is validation even necessary? Perhaps it would be ideal to just show an error if it fails to connect, like the websockets do, then to handle each edge case in regexes?
Author
Owner

@liyasthomas commented on GitHub (Aug 25, 2019):

Sooner or later, URL validation will be necessary. Anyway let's discuss.

<!-- gh-comment-id:524592831 --> @liyasthomas commented on GitHub (Aug 25, 2019): Sooner or later, URL validation will be necessary. Anyway let's discuss.
Author
Owner

@NBTX commented on GitHub (Aug 25, 2019):

Okay. I'll update the url validation to include the two regex checks in the mean time.

<!-- gh-comment-id:524592902 --> @NBTX commented on GitHub (Aug 25, 2019): Okay. I'll update the url validation to include the two regex checks in the mean time.
Author
Owner

@liyasthomas commented on GitHub (Aug 25, 2019):

@NBTX sendRequest() isn't firing. Can you check changes on URL validation

<!-- gh-comment-id:524594485 --> @liyasthomas commented on GitHub (Aug 25, 2019): @NBTX sendRequest() isn't firing. Can you check changes on URL validation
Author
Owner

@NBTX commented on GitHub (Aug 25, 2019):

Solved by #58

<!-- gh-comment-id:524630460 --> @NBTX commented on GitHub (Aug 25, 2019): Solved by #58
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/hoppscotch#19
No description provided.