Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Register link doesn't work #99

Open
cszczepaniak opened this issue Aug 29, 2021 · 1 comment
Open

Register link doesn't work #99

cszczepaniak opened this issue Aug 29, 2021 · 1 comment

Comments

@cszczepaniak
Copy link
Collaborator

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
Copy link
Collaborator Author

cszczepaniak commented Aug 30, 2021

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:

  • For local dev: since we're about to start using docker-compose anyway, we should just build a separate frontend container that serves the react app separately from the API. If we want to preserve WASM, maybe the same would work? Unclear.
  • For prod/deployed: host the react app in an S3 bucket fronted with CloudFront. It can make REST calls to the backend (wherever that may be), but logically it will be separated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant