#712·choo

Usage with http-server

Author: rook2pawnCreated Oct 9, 2021Updated Nov 7, 2021

Expected behavior

from my package.json

"start": "http-server -o -c-1 -p 8080 --proxy http://localhost:8080/ ",

This indeed loads up the app properly at http://127.0.0.1:8080/ However

javascript
  function joinView(state, emit) {
    return html`<body>
      <div><h4>Join!</h4></div>
    </body>`;
  }
  function lobby(state, emit) {
    return html`<body>
      <div>
        <h4>Lobby</h4>
        <a href="/join">Join</a>
      </div>
    </body>`;
  }
  app.use(devtools());
  app.use((state) => {
    state.logger = false;
  });
  app.route("/join", joinView);
  app.route("/", lobby);
  app.mount("body");

If i click the link "Join" from within the app, the router properly pushStates to /join and renders the joinView but if I reload so that the browser tries to request /join... i run into a loop because I'm trying to force http-server to do a catchall and serve my index.html which just has a simple div.

xml
<html>
  <head>
    <script src="bundle.js"></script>
  </head>
  <body></body>
</html>

What precisely should I do to handle navigating directly to /join? Without the proxy statement /join doesn't exist because its not really something available outside the SPA. @YerkoPalma