question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

The question mark in the proxy example in the doc `-P http://localhost:8080?` is causing issue

See original GitHub issue

Steps to reproduce the issue, if applicable. Include the actual command and output and/or stack trace.

I ran http-server /data -p 80 -P http://localhost:8080? as suggested in the doc. When I hit http://localhost/test, my downstream server (which listening on 8080) get /?/test

What did you expect to happen?

Maybe I don’t understand the purpose of the ? at the end. Removing the ? fix the issue. Is this a mistake in the doc or I missed anything?

Tell us about your environment

  • exact http-server version: 0.12.3
  • Node version: 12.18.3
  • Platform: Windows 10

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
elwinschmitzcommented, Sep 8, 2020

I think I had the same misunderstanding of that section in the README; As I thought it was explaining the use of the --proxy-option, but actually it isn’t. (See the discussion: https://github.com/http-party/http-server/issues/338#issuecomment-338601211)

That section in the README tries to explain a clever ‘workaround’ for when you want to test a Single-Page-App which handles its own urls (like Angular/React/Vue can with their Router-components).

The use-case you are looking for (similar to mine, I think), is to run your static front-end on http://loocalhost:80 and let all requests to /api/ for example, go to http://back-end.example.com/api/ (or locally to http://localhost:8080/api/)

To do that, you would be using ‘just’ the --proxy-option: npx http-server --port 80 --proxy http://back-end.example.com/

The ? in the URL in the README is only there to ‘pass’ the rest of the URL to your local index.html and let your framework’s Router handle it.

0reactions
rook2pawncommented, Dec 18, 2021

diagram is the basic setup that i use - what’s nice about this approach is that you have a clean separation between your SPA and your BE (repo, hosting/instances) and you can even put all sorts of things at your proxy level (administrative redirects, prevent spam attacks) so your logic on your SPA/BE/proxy are all cleanly split into the domains they are best suited for. i setup a small repo that ties this all together but you can do this setup on any framework you want.

Read more comments on GitHub >

github_iconTop Results From Across the Web

problem in apache httpd.conf with question mark character
From the documentation for ProxyPass: url is a partial URL for the remote server and cannot include a query string. In your example,...
Read more >
Is the Proxy Setting Causing a Problem? - Oracle Help Center
Solution. A server instance running on localhost might not be accessible if the server host machine is connected to the web through a...
Read more >
Networking Guide Red Hat Enterprise Linux 7
The Red Hat Enterprise Linux 7 Networking Guide documents relevant information regarding the configuration and administration of network interfaces, ...
Read more >
How to Make Secure HTTP Requests with Vue and Express
This is where you'll fill out some important information that allows the Auth0 application to connect to your Vue application. Fill these out...
Read more >
Apache 2.4 + PHP-FPM + ProxyPassMatch - Server Fault
I ran into this problem yesterday as well – Apache 2.4 moved out of ... In your fpm pool configuration, don't pass the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found