How to enable CORS for your website?

A request for the website resource like images or fonts from outside of the origin website is known as a cross-origin request. It is a security mechanism that allows restricted resources like fonts, JavaScript code etc. on a website page to be requested from a 3rd party domain outside the domain from which these resources were served. Using CORS, you can control the website resources on who can access it.

CORS on a website hosted on Linux Environment

You can add the below line in your .htaccess file where cross-domain scripting is required.

<ifModule mod_headers.c>
Header set Access-Control-Allow-Origin: *
</ifModule>

CORS on a website hosted on Windows Environment

For Windows hosting accounts, create or modify the web.config file in the directory where you want to permit CORS requests. Add the following lines to the web.config file:

To enable CORS on the windows website, you can just add the below lines.

<configuration>
   <system.webServer>
     <httpProtocol>
       <customHeaders>
           <add name="Access-Control-Allow-Origin" value="*" />
        </customHeaders>
     </httpProtocol>
   </system.webServer>
</configuration>

Related Articles

How ImunifyAV+ is useful?

ImunifyAV+ is an effective anti-malware service. It is used to scan and detect the malware lied...

Why my order is showing as a fraud?

We at Accuwebhosting have an automated order verification system that verifies your order...

Comparison of control panels Plesk VS WHM/cPanel.

Web Hosting control panels are very useful to manage your servers with a front-end graphical web...

How to enable TLS in Google Chrome, Mozilla Firefox and Internet Explorer?

Here are the steps you can follow to enable TLS in different browsers: Firefox Type...

How do I check current established connections and network utilization of my VPS?

Windows VPS   For current established connections and processes:   Go to Run Type cmd, hit...

  • 0 Users Found This Useful

Was this answer helpful?