Skip to content

Usage with http-server #712

Open
Open
@rook2pawn

Description

@rook2pawn

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

  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.

<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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions