Andrew Arrow
Andrew Arrow

Reputation: 4585

How do I fix sudden CORS error from zendesk app?

Cross-Origin Request Blocked: 
The Same Origin Policy disallows reading the remote resource at 
https://myserver.com/marketplace/foo?test=123. 
(Reason: CORS request did not succeed). 
Status code: (null).

There was a problem with the fetch operation: 

TypeError: NetworkError when attempting to fetch resource. 
from origin: https://1061842.apps.zdusercontent.com/

We have an app in production and set:

Access-Control-Allow-Origin: https://1061842.apps.zdusercontent.com

  c.Writer.Header().Set("Access-Control-Allow-Origin", fmt.Sprintf("https://%s.apps.zdusercontent.com", id))
  c.Writer.Header().Set("Access-Control-Allow-Headers", "*")
  c.Writer.Header().Set("Access-Control-Allow-Methods", "*")

where id comes from 1061842 in the origin.

  origin := c.Request.Header.Get("Origin")

  tokens := strings.Split(origin[8:], ".")
  id := tokens[0]

and it was working fine for months. Then all of a sudden last night we get this error.

Upvotes: 1

Views: 234

Answers (0)

Related Questions