简体   繁体   English

Freshdesk API CORS问题

[英]Freshdesk API CORS issue

I'm trying to access the api of my helpdesk. 我正在尝试访问我的帮助台的api。 I want to create a ticket automatically, like "hit the button" and create a default ticket. 我想自动创建故障单,例如“点击按钮”并创建默认故障单。

So, I am programming a POST method to my tickets.json , but I always get an ERROR: 所以,我正在为我的tickets.json编写一个POST方法,但是我总是收到一个错误:

SEC7118: XMLHttpRequest para http://XXXX.freshdesk.com/helpdesk/tickets.json exigia CORS (Compartilhamento de Recursos entre Origens). SEC7118:XMLHttpRequest段http://XXXX.freshdesk.com/helpdesk/tickets.json exigia CORS(源于原始文件)。

SEC7119: XMLHttpRequest para http://XXXX.freshdesk.com/helpdesk/tickets.json exigia simulação de CORS. SEC7119:XMLHttpRequest参数位于 http://XXXX.freshdesk.com/helpdesk/tickets.json exigiasimulaçãode CORS。

So, as you can see, it's a CORS error 如您所见,这是CORS错误

I'm following the authorization requirement by using it in the header of my request 我在请求的标头中使用授权要求

Authorization: Basic encode64('login':'pw') 授权:基本encode64('login':'pw')

But, I still have this issue. 但是,我仍然有这个问题。

PS: There is a ticket in freshdesk too. PS:freshdesk也有一张票。 https://support.freshdesk.com/support/tickets/112829 https://support.freshdesk.com/support/tickets/112829

Not exactly the answer, but an alternative approach is to use your webserver as a reverse proxy to the backend. 不完全是答案,而是一种替代方法是将您的Web服务器用作后端的反向代理。 With nginx this can be achieved like this: (this goes in the "server" block) 使用nginx,可以这样实现:(这在“服务器”块中)

location /api {
  proxy_pass https://api.backend.com/v1;
  proxy_redirect off;
}

Here is a link that describes it in some more detail: http://www.cyberciti.biz/tips/using-nginx-as-reverse-proxy.html 以下是对此链接进行更详细描述的链接: http : //www.cyberciti.biz/tips/using-nginx-as-reverse-proxy.html

For apache: https://www.digitalocean.com/community/articles/how-to-use-apache-http-server-as-reverse-proxy-using-mod_proxy-extension 对于apache: https : //www.digitalocean.com/community/articles/how-to-use-apache-http-server-as-reverse-proxy-using-mod_proxy-extension

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM