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

Post queries? #25

Closed
gorbs opened this issue Apr 21, 2016 · 2 comments
Closed

Post queries? #25

gorbs opened this issue Apr 21, 2016 · 2 comments

Comments

@gorbs
Copy link

gorbs commented Apr 21, 2016

Using the react-starterkit setup and have added a new route /authenticate. When I post to the route, I get a response "Cannot POST /authenticate". However, it will happily route to it via a GET.

for example:
on('/authenticate', async () => <div>hello</div>);
will error with a POST, but return the element with a GET. Does the router support POST operations or am I doing something very wrong?

@langpavel
Copy link
Collaborator

I think you do not instrument express to handle HTTP POST method in server.js.
Please read more about express.

@koistya
Copy link
Member

koistya commented Apr 22, 2016

This router is only supposed to be used with GET HTTP requests for rendering React apps on the server and on the client. To add /authenticate endpoint on the server, you can use Express functionality, for example, in server.js:

app.post('/authenticate', (req, res) => {
  // todo: validate user, issue an authentication token
});

@koistya koistya closed this as completed Apr 22, 2016
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

3 participants