joshprzybyszewski / cribbage

A cribbage scorer and game
MIT License
2 stars 1 forks source link

Register link doesn't work #99

Open cszczepaniak opened 3 years ago

cszczepaniak commented 3 years ago

On the login page, we have a link that is supposed to take you to the register page. Right now it gives you a 404. Also, adding /register to the URL also gives a 404, but clicking the register button in the left drawer does work. Make everything not be broken.

cszczepaniak commented 3 years ago

After some research and tinkering, I found the reason for this:

func (cs *cribbageServer) addReactHandlers(router *gin.Engine) {
    // Serve frontend React static files
    router.Use(static.Serve(`/`, static.LocalFile(`./client/build`, true)))
}

We serve the react application from exactly one route: /

When the user types /register into their browser (or clicks an <a> element, which is what the mentioned link is), gin doesn't map it to the react app, but instead looks for a matching route. The fix would be to match any path from the browser and route them to /, but matching any path means potential conflicts with existing API (or WASM) routes.

My recommendation is to do the following: