Is this a cross-domain issue? And the science of my forwarding processing scheme? Will there be a pit? Why do people taunt this proposal?

Source: Internet
Author: User
Tags php website
The thing is this:
1. The same server, PHP website is 80 port, C # WebService is 81 port.
2. Client, use Ajax to get data from WebService. Ajax is a PHP web site, with 80 ports.
3. Using Chrome debugging, Error "' Access-control-allow-origin '", checked, said to be a cross-domain problem.

Question 1: Is this a cross-domain issue?

4. Searching the internet for half a day, most of the solutions are very complex and need to change the WebService code.
I think: if because of cross-domain problem, changed the WebService code, not when I do not cross the domain, the code will have to change all back?
This is obviously unscientific.

5. I feel that the cross-domain problem in my case, due to the webservcei port, is inconsistent with the PHP Web port, causing the URL to be visited changed, causing cross-domain problems. So, the solution is also very simple, with the TCP tool, do a forwarding is not OK?

6. Since PHP is using Apache, I have directly configured the forwarding in Apache, that is, reverse proxy, the 80 port forwarding to 81,ajax successfully obtained to WebService data, problem resolution.

7. Here's my question:
With simple configuration forwarding, you can easily take care of this and do not need to modify the WebService code. So, why do I put this thing in QQ group to say again, a lot of people say taunt?

Reply content:

The thing is this:
1. The same server, PHP website is 80 port, C # WebService is 81 port.
2. Client, use Ajax to get data from WebService. Ajax is a PHP web site, with 80 ports.
3. Using Chrome debugging, Error "' Access-control-allow-origin '", checked, said to be a cross-domain problem.

Question 1: Is this a cross-domain issue?

4. Searching the internet for half a day, most of the solutions are very complex and need to change the WebService code.
I think: if because of cross-domain problem, changed the WebService code, not when I do not cross the domain, the code will have to change all back?
This is obviously unscientific.

5. I feel that the cross-domain problem in my case, due to the webservcei port, is inconsistent with the PHP Web port, causing the URL to be visited changed, causing cross-domain problems. So, the solution is also very simple, with the TCP tool, do a forwarding is not OK?

6. Since PHP is using Apache, I have directly configured the forwarding in Apache, that is, reverse proxy, the 80 port forwarding to 81,ajax successfully obtained to WebService data, problem resolution.

7. Here's my question:
With simple configuration forwarding, you can easily take care of this and do not need to modify the WebService code. So, why do I put this thing in QQ group to say again, a lot of people say taunt?

The browser's same-origin policy requires the protocol, domain name, and port to be exactly the same, so this is a cross-domain issue

To solve cross-domain problems, server-side forwarding is one of the solutions, and there is no need to change the other end of the code, like cors or JSONP need the other end of the support

As for a lot of people who say taunt ... I can't answer that.

Do not know why taunt ...

My elasticsearch because to give more people to use, I again on the server on the Nginx anti-generation added Pam authentication.

The scheme is fine, but if the sub-site is more likely to be more cumbersome to configure, and modify the server configuration is not as easy as modifying the js,php.
Recommended JSONP

Perhaps mocking is the architecture of standalone windows,c++++ and PHP?

Also recommended JSONP processing, simple rude, if the SVR return code cannot be modified and then consider the reverse proxy

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.