This is a question related to https://social.msdn.microsoft.com/Forums/en-US/6e856136-9a39-4b98-a53d-7f8bce08e3a6/cors-support-for-bing-translate-api
Does the Microsoft Azure Translate API support CORS now?
This is a question related to https://social.msdn.microsoft.com/Forums/en-US/6e856136-9a39-4b98-a53d-7f8bce08e3a6/cors-support-for-bing-translate-api
Does the Microsoft Azure Translate API support CORS now?
The Microsoft Translator Text API appears to at least minimally now support CORS, in that it does at least seem to send the
Access-Control-Allow-Origin
header in responses:I don’t personally have a valid
appid
to test with—but if you do, I think you’ll find it’ll work:GET
endpoints from the https://docs.microsofttranslator.com/text-translate.html docsappid
parameter instead of theAuthorization
request headerIf may also work for the https://docs.microsofttranslator.com/text-translate.html
POST
endpoints—as long as your requests don’t use theAuthorization
request header or set aContent-Type
.The problem with those headers is, they’ll trigger browsers to do a preflight
OPTIONS
request:https://developer.mozilla.org/en-US/docs/Web/HTTP/Access_control_CORS#Preflighted_requests
And the problem with making calls to those API endpoints that trigger a preflight is, they don’t seem to respond to
OPTIONS
requests in a way that’ll cause browsers to see the preflight as a success.At https://docs.microsofttranslator.com/text-translate.html#!/default/post_TranslateArray I notice the docs say that endpoint expects a
POST
with anapplication/xml
ortext/xml
Content-Type
, so if that endpoint doesn’t respond to preflightOPTIONS
in the right way, that one won’t work.That’s because adding an
Content-Type: application/xml
orContent-Type: text/xml
header to a request will definitely trigger browsers to do a preflightOPTIONS
before thePOST
.