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

Isomorphic form submission #67

Closed
cmgriffing opened this issue Mar 31, 2015 · 1 comment
Closed

Isomorphic form submission #67

cmgriffing opened this issue Mar 31, 2015 · 1 comment

Comments

@cmgriffing
Copy link

Hi, I am making this an issue instead of pull request until an idiomatic way of doing this is agreed upon.

The idea is that if a user has JS disabled, React renders a url-encoded form instead of an ajax powered one. Without the modification to fetchr linked below, the form does not redirect to the referrer when url-encoded form submission occurs so the json response is all the user would see. Instead, I have added a redirect to referrer.

Here is the commit in question (on my fork): cmgriffing@0f7dcc5

It simply detects a urlencoded form and redirects back to the referrer url.

This is in relation to proof of concept code here: cmgriffing/isomorphic-porch-demo@ef28c23

I think that modifying the middleware function of fetchr is a bit of a hack. A proper solution would let the "user" decide to implement a redirect inside of the Service callback. However, I wanted to check with you over whether adding the res object to the callback args is the right way to proceed or if middleware modification is actually the best place to detect url-encoded form submission.

I also think that requiring a redirectUrl by convention to the React form might be necessary instead of redirecting to 'back'.

Thanks,
-Chris

@Vijar
Copy link
Contributor

Vijar commented Jul 7, 2015

@cmgriffing I think the best way to handle this would be to support internal fetchr middleware. Something along the lines of #61. That way you can get increased app specific customization (e.g. limiting form redirect logic to only a few resources, adding authentication to other resources) while still keeping fetchr generic.

I'm going to close this issue. You can tack #61 for progress on custom middleware.

@Vijar Vijar closed this as completed Jul 7, 2015
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

2 participants