Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cross domain restrictions and subdomains

Is there a cross domain policy restriction for subdomains?

If I have an application on paint.xxxx.com which is manipulating images from image.xxxx.com, are there any cross domain problems?

I'm asking these questions, because I'm considering putting a proxy on a subdomain.

like image 896
mcbjam Avatar asked May 19 '13 23:05

mcbjam


People also ask

Is subdomain considered cross domain?

Sub-domains are considered different and will fail the Same Origin Policy unless both sub-domains declare the same document. domain DOM property (and even then, different browsers behave differently).

Does cross origin apply with subdomains?

Yes you have to enable it. You have to send CORS allow headers from server side to your browser. This is because a subdomain counts as a different origin.

Are different ports considered cross domain?

Websites that have the combination of the same scheme, hostname, and port are considered "same-origin". Everything else is considered "cross-origin".

What are subdomains on a website?

A subdomain name is a piece of additional information added to the beginning of a website's domain name. It allows websites to separate and organize content for a specific function — such as a blog or an online store — from the rest of your website.


1 Answers

yes the cross domain restriction applies for subdomains.

The solution is to put

document.domain = "example.com" ; // whatever your domain name is

in the top of the js file(s) for both the parent domain and the child domain

Google Document.domain and cross site and there should be a better explanation but I've had the same issue and that is what worked for me.

like image 125
smugford Avatar answered Sep 24 '22 14:09

smugford