Cross-Origin Resource Sharing

Web hosting discussion, programming, and shared and dedicated servers.
2 posts Page 1 of 1
by gpelpel » Tue May 09, 2017 11:04 pm
Does support cross-origin resource sharing?
I have some javascript codes that call an external server via Ajax commands. They work great on all other systems but not on Sonic. Is there a setting to activate?
by drew.phillips » Thu May 11, 2017 3:53 pm
Can you elaborate on the specifics of what domain you're trying to perform an Ajax request to?

If you're site is hosted on Sonic and you're trying to make an Ajax request to a remote domain, then Sonic doesn't need to support anything; it's up to the browser and the remote site to permit/deny the request.

If you're trying to make an Ajax request to a Sonic hosted site, then you'll need to configure that site/URI to send the appropriate headers to permit it from the calling domain.

Since you can only specify one domain per request, it often takes some kind of code or special .htaccess rules to apply the CORS headers correctly.

For example, in PHP:

Code: Select all

$http_origin = @$_SERVER['HTTP_ORIGIN'];
if (
    preg_match('/domain1\.com$', $http_origin) ||
    preg_match('/domain2\.com$/', $http_origin) ||
    preg_match('/third-domain\.net$/', $http_origin)
) {
    header('Access-Control-Allow-Origin: ' . $http_origin);

Basically, we fully support it. is a good place to get help with programming issues like this as well.

Good luck!
Drew Phillips
Programmer / System Operations,
2 posts Page 1 of 1

Who is online

In total there are 6 users online :: 0 registered, 0 hidden and 6 guests (based on users active over the past 5 minutes)
Most users ever online was 700 on Thu Jun 18, 2020 12:00 pm

Users browsing this forum: No registered users and 6 guests