Describe the problem
I want to do a +server.ts with a POST handler that downloads a file (a JSON backup).
And I want it to be accessible without client-side javascript:
<!-- backup/+page.svelte -->
<form method="POST" action="/backup">
<input type="submit">
</form>
// backup/+server.ts
export const POST = () => {
return new Response(JSON.stringify('{}'), {
headers: {
'Content-Type': 'application/json',
'Content-Disposition': 'attachment; filename="backup.json"'
}
})
}
Unfortunately, there is a 405 error message with the message:
POST method not allowed. No actions exist for this page
This, despite the lack of +page.server.ts / actions.
Describe the proposed solution
When there is no actions for a page, allow the POST from the native browser form to hit +server.ts's POST handler.
This would be consistent with the GET behavior.
Alternatives considered
Currently, workarounds are using client-side javascript, or redirecting to a GET page in the action's handler.
A possible alternative feature is allow downloading files in an action handler.
Importance
nice to have
Additional Information
No response
Describe the problem
I want to do a
+server.tswith aPOSThandler that downloads a file (a JSON backup).And I want it to be accessible without client-side javascript:
Unfortunately, there is a 405 error message with the message:
This, despite the lack of
+page.server.ts/ actions.Describe the proposed solution
When there is no actions for a page, allow the POST from the native browser form to hit
+server.ts'sPOSThandler.This would be consistent with the GET behavior.
Alternatives considered
Currently, workarounds are using client-side javascript, or redirecting to a GET page in the action's handler.
A possible alternative feature is allow downloading files in an action handler.
Importance
nice to have
Additional Information
No response