Suddenly encountered a cross-domain error.

We have a page using Ext.js that works locally, deploys to the server, and doesn’t get any data. F12 debugging, a cross – domain error?

XMLHttpRequest always load http://192.168.0.22:8080/cas/login? Service = HTTP % 3 a % 2 f % 2 f192 168.0.22%2 FGJ. W... El%3d0%26numberfield-1024-inputEl%3d20%26page%3d1%26start%3d0%26limit%3d20. No 'Access-Control-Allow-Origin' header is Present on the requested resource. Origin 'http://192.168.0.22' is therefore not allowed access.Copy the code

This is a cross – domain error. What’s going on?

http://192.168.0.22:8080/cas, the site looked at is known, is a single sign-on (SSO) web site (hereinafter referred to as for SSO site). Our page is deployed under site A. Do you want to configure under SSO? I felt a twinge of fear at the thought. Because SSO is done in Java.

But was quick to dismiss the reason. Because a similar page is deployed under site B and is logged in with SSO, there is no problem.

Is the problem under site A? Went through all the configurations, found nothing wrong.

Then I remembered that this page uses Ext.js, and that the various JS files of ext.js are deployed in a virtual directory that belongs to site B. Delete the virtual directory and redeploy it to the root directory of the website, alongside sites A and B, as shown in the picture. The problem is solved.

My guess is that ext.js caused a cross-domain error. For B, it’s in its domain, no problem; For A, different domains (strictly speaking, different subdomains) request JS in different domains, causing cross-domain problems.