How the front-end Web development HTML avoids JS cross-domain access

Source: Internet
Author: User

Several pages were developed today, but some of the HTTP interfaces on the page were called to render the page, because of cross-domain issues, but did not want to make the JSONP way, so get an Apache HTTP server to toss. This applies only to Linux

1. Download Apache httpd from Apache

2. After downloading the installation directory, open the httpd.conf configuration file of the Conf folder to modify

3. First modify the listen port such as 8081, after the change to save (because the default 80 ports may be occupied, so modify their own definition)

Listen 8088

4. Open the httpd boot of the bin folder in the installation directory

./httpd-x

5. Open the browser input localhost:8088, you can find it works! Hint, this means the boot was successful.

But if I need to replace some of my static HTML pages and JS, such as I have a static page project WebApp, I put to/usr/local/apache2/webapp (of course, I can specify to put in other directories)

So open httpd.conf and find the following

documentroot  "/usr/local/apache2/htdocs" <Directory  "/usr/local/apache2/htdocs" >     #    # possible values for the options directive  are  "None",  "All",    # or any combination of:     #   Indexes Includes FollowSymLinks SymLinksifOwnerMatch  execcgi multiviews    #    # note that  "MultiViews " must be named *explicitly* --- " options all "    # &NBSP;DOESN ' t give it to you.    #    # the  options directive is both complicated and important.  please  see    # http://httpd.apache.org/docs/2.4/mod/core.html#options     # for mOre information.    #    options indexes followsymlinks     #    # allowoverride controls what directives  may be placed in .htaccess files.    # it can  be  "All",  "None", or any combination of the keywords:     #   AllowOverride FileInfo AuthConfig Limit     #    AllowOverride None    #    #  controls who can get stuff from this server.    #     Require all granted</Directory>

Replace/usr/local/apache2/htdocs with/usr/local/apache2/webapp

documentroot  "/usr/local/apache2/webapp" <Directory  "/usr/local/apache2/webapp" >     #    # possible values for the options directive  are  "None",  "All",    # or any combination of:     #   Indexes Includes FollowSymLinks SymLinksifOwnerMatch  execcgi multiviews    #    # note that  "MultiViews " must be named *explicitly* --- " options all "    # &NBSP;DOESN ' t give it to you.    #    # the  options directive is both complicated and important.  please  see    # http://httpd.apache.org/docs/2.4/mod/core.html#options     # for mOre information.    #    options indexes followsymlinks     #    # allowoverride controls what directives  may be placed in .htaccess files.    # it can  be  "All",  "None", or any combination of the keywords:     #   AllowOverride FileInfo AuthConfig Limit     #    AllowOverride None    #    #  controls who can get stuff from this server.    #     Require all granted</Directory>

After saving, restart httpd again to access the other normally.


How the front-end Web development HTML avoids JS cross-domain access

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.