Jump to content

OT: coding ajax request to domain from local host


Recommended Posts

Posted

This is off topic from emby, but is regarding web servers.

 

If you own a domain ('example.com'), and have it point back to a self hosted server on your computer, and you want to access a json file on your computer.

You can drop the json file into the server folder and use 'example.com/example.json" to view the file.

But, you can't test Web requests to the domain or view that file from any computer on the same LAN as the web server.

 

Further more, when making Ajax request from a web page on the server, to try and access the json file, you can't access the file system of the server because of "cross origin" security measures.

 

 

 

What is the best practice for this situation?

 

 

What is the best practice for development when hosting your own web server and you want to access the domain from inside the web servers LAN?

 

I hope I have made my issue clear enough to find an answer.

Google hasn't been kind to me...

 

I'd love to read some articles on what to do if anyone has any resources to link to.

 

Many thanks!

mastrmind11
Posted (edited)

Sounds like you're referring to cross site scripting (XSS), which is a big no-no and sites go through great length to protect against it.  Here's an article about how to get around it:  http://infoheap.com/bypass-xss-protection-by-browsers/

Edited by mastrmind11
Posted

Sounds like you're referring to cross site scripting (XSS), which is a big no-no and sites go through great length to protect against it.  Here's an article about how to get around it:  http://infoheap.com/bypass-xss-protection-by-browsers/

 

There's very good reason for this.

 

I'm not sure why you would want to do this, why not just sync the file to the web server you are using for development? The way I work and the way it's done where I work, is that we do our development within a directory exported by a local lamp stack - all changes are managed through git and then once a release is finalized it gets pushed to a production web server.

 

I suppose if you had to do this then you would use whatever server side language you are using, to grab the file and then you would add some routing to access that file via the same application i.e. a proxy.

  • Like 1
mastrmind11
Posted

I agree with everything you said, I was simply pointing out a workaround for internal testing or whatever. I'd never recommend doing it in the wild.

 

Sent from my SM-G950U using Tapatalk

Posted (edited)

Thanks for the references.

 

I suppose for most developers who are building sites and web services, write them on local host and then put them "into the wild".

 

Im starting to realize how server back ends work, but it seems to get complicated quickly.

Edited by chef

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...