Closed rclement closed 3 years ago
Some more specifications.
Optional new configurations:
SUCCESS_REDIRECT_URL
: redirect to this URL after an e-mail has been successfully submitted using the form submission APIERROR_REDIRECT_URL
: redirect to this URL if an error occurred when submitting an e-mail using the form submission APIQuestion: these configurations are required when using the form submission API? Do we redirect to Origin
when not specified?
/api/email/form
: form submission API with parameters accepted as application/x-www-form-urlencoded
content-type
Currently, only a JSON API endpoint is available at
/api/mail
. When using SSG without JS AJAX support, sending form with a simple HTTP POST request using theapplication/x-www-form-urlencoded
content-type would be a nice universal and fallback solution.However, FastAPI does not allow multiple content-type body request for a single route:
The preferred way seems to go towards having separate routes based on content-type.
One more thing: when using a POST form submission, redirections will be required! One easy way to do it would be to setup:
This pattern is called "POST/Redirect/GET": https://en.wikipedia.org/wiki/Post/Redirect/Get
As a reference, Formspree is doing something similar with its "Thank You Redirect": https://help.formspree.io/hc/en-us/articles/360012378333--Thank-You-redirect