-
Notifications
You must be signed in to change notification settings - Fork 0
Cross Origin Resource Sharing
Cross-origin resource sharing (CORS) is a mechanism that allows restricted resources (e.g. fonts) on a web page to be requested from another domain outside the domain from which the first resource was served. A web page may freely embed cross-origin images, stylesheets, scripts, iframes, and videos. Certain "cross-domain" requests, notably Ajax requests, are forbidden by default by the same-origin security policy.
https://en.wikipedia.org/wiki/Cross-origin_resource_sharing
A problem you will encounter upon first usage from a web page is the server will respond with a status code 400 (Bad Request). This is due to Cross-origin resource sharing and so you'll need to add in the domain you're posting from as a cors setting in the portal. To do this:
- Go to the Resource Group in the Azure Portal
- Click on the Function
- Platform features > CORS
- Add a new value: note: for most browsers there is no easy way to turn this off for local domains so use "*" and remove all other values. If you are testing on a domain then use that e.g "http://yourDomain.com"
- Save
Note: For security reasons it would be best to remove the "*" all when you're finished testing locally. You don't want any domain using your function to post things to.
You should now be able to post from a web page.