Posts

Showing posts with the label cross-domain

Cors in Ajax Meet 302 Redirect

Image
Clash Royale CLAN TAG #URR8PPP Cors in Ajax Meet 302 Redirect I have a front-end server with port 8081 a background server with port 8080(Spring MVC + shiro) When I send a request to 8080 , I have to set the cors headers on 8080 if the request is a simply request which only returns some json datas, it works But When the response status is 302, Chrome shows 'Redirect from 'http://localhost:8080/' to 'http://localhost:8080/' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.' I thought there are two reasons to occur this problem: ① if I intercept this 302 status, and deal this response.headers.Location, I will solve this. But I can't intercept this response(with axios) ② Maybe some settings is wrong with 8080 server, when 302 occurs, the serve haven't set the cors Headers for this page. But I don't understand the backend code. So, ① is feasible? or I need to change the settings on 808...

Cross domain from browser to express server doesn't work

Image
Clash Royale CLAN TAG #URR8PPP Cross domain from browser to express server doesn't work I know this has been asked more than a hundred times... I did look into most of the information I found, and think I did understand the process, cause I was able to configure my s3 to allow cross domain access.. my express configuration: this.express = new Express(); this.express.all("*", (req, res, next) => { res.setHeader('Access-Control-Allow-Origin', "*"); res.setHeader('Access-Control-Allow-Methods', "POST"); res.setHeader('Access-Control-Allow-Headers', "content-type"); next(); }).options((req, res, next) => { res.end(); }); *I add a router down the modules folder hierarchy.. When I check the network tab this is what I see: I think that I have answered the CORS challenge, in the pre-flight OPTIONS request, but the second request is not called... WHY? ...