[SalesForce] XMLHttpRequest cannot load visual.force.com as requested origin is thedomainname.the.salesforce.com

XMLHttpRequest cannot load
https://mydomainname–c.eu1.visual.force.com/apex/OpportunityOneClickUpdate?id=006D000000ZRwtx.
No 'Access-Control-Allow-Origin' header is present on the requested
resource. Origin 'https://mydomainname.my.salesforce.com' is
therefore not allowed access.

A Inline Visualforce page is throwing above error when It's calling action function. Even if this visualforce page is opened independently (and not inline) still its giving above error. Strange part is its working fine for almost all customers and not working for just one customer.

For this customer, its failing as request and origin are both from different domain, so its giving access not allowed error. Not sure why request and origin domain are coming as different.

  1. the request url is mydomainname–c.eu1.visual.force.com
  2. origin is mydomainname.my.salesforce.com

I tried similar stuff in another org (with mydomain enabled and same settings) and everything is working fine there.

  1. the request url is mydomainname–c.eu1.visual.force.com
  2. origin is mydomainname–c.eu1.visual.force.com

Already I've followed other posts too (talking about similar issue), but none really helped wrt how to address my (this post) issue:

  1. https://salesforce.stackexchange.com/questions/55676/vf-pages-fail-with-xmlhttprequest-error-no-access-control-allow-origin-heade
  2. XMLHttpRequest cannot load, No 'Access-Control-Allow-Origin' is present

Any clue or feedback on why its failing for few customers (or why the domain and origin are appearing different for certain customers) and not for others? Seems there's something small that I'm missing or some configuration that I need to get enabled (by requesting to Salesforce). Any input in this direction will be really appreciated.

Best Answer

Customer reached out to Salesforce Support and got turned OFF "Enables VF pages to be served from thesalesforce.com domain" permission. This solved the issue.

So if anyone faces similar issue, without thinking twice please raise case with Salesforce Support requesting to turn OFF "Enables VF pages to be served from thesalesforce.com domain" permission.

Thank you everyone!

Related Topic