|
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. |
Replies: 2 comments
|
What I did was add an additional |
|
The SvelteKit starter app does this via an In the You can see further discussion on this issue: #1203 (comment). |
The SvelteKit starter app does this via an
enhanceaction on the form. If JS is enabled, then theenhanceaction runs and submits the form via fetch. Otherwise, it does a regular form submit.In the
/formendpoint, 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).