-
I am developing a website that must support users without Javascript - this means that I must ensure HTML forms work properly without any enhancements. This raises a problem: all my endpoints are designed as part of a REST API, so they return JSON, but when working with basic HTML forms only, the server must handle redirections and respond with actual HTML. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
What I did was add an additional |
Beta Was this translation helpful? Give feedback.
-
The SvelteKit starter app does this via an In the You can see further discussion on this issue: #1203 (comment). |
Beta Was this translation helpful? Give feedback.
The SvelteKit starter app does this via an
enhance
action on the form. If JS is enabled, then theenhance
action runs and submits the form via fetch. Otherwise, it does a regular form submit.In the
/form
endpoint, it detects if the submission was via fetch or regular form submission. If it was a regular form submission, then it performs a redirect instead of returning JSON.You can see further discussion on this issue: #1203 (comment).