Salesforce Web to lead and Web to Case using Javascript [CORS Proof !]
Ever faced a CORS issue while trying to embed Web to lead or Web to Case in your website?
CORS
Cross-Origin Resource Sharing (CORS) is an HTTP-header-based mechanism that allows a server to indicate any origins (domain, scheme, or port) other than its own from which a browser should permit loading resources.
Cross-Origin Resource Sharing (CORS) errors occur when a server doesn’t return the HTTP headers required by the CORS standard. To resolve a CORS error from an API Gateway REST API or HTTP API, you must reconfigure the API to meet the CORS standard.
Solution
Here’s a workaround using the form in HTML and processing it through Javascript.
Happy Coding!