1
votes

I'm building a Shopify website and I'm trying to create a simple "Contact Us" page that allows the user to POST their comments (e.g. name, email, comments). The Shopify website is hosted (as all Shopify accounts are) but I can set up a CNAME from my domain to point the Shopify hosted pages (that way I have a vanity URL).

I'm wondering, will this enable me to POST directly from the Shopify hosted pages to a script on my server?

Example: The Shopify pages are at: http://myawesomestore.shopify.com On my contact-us page: http://myawesomestore.shopify.com/pages/contact-us/ I want to POST to a script on my domain (where I can store in a database): www.my-domain.com/contact-us.php

If I cannot do this, what is the best solution for posting from a hosted solution to an owned solution (i.e. I cannot set up a proxy on their domain to POST to mine).

I hope this makes sense, I'm still very much a novice and there are just too many fundamentals here to comprehend before I could logically build this solution myself.

Thank you all so much in advance!

Cheers, Rob

4
you don't need a cname, if you can set up a html form you can post it to any url on the net.user557846
@Dagon27, I thought you couldn't do that because of cross-server security?sapiensgladio
post is a standard http header, you cant really have a webserver and it not accept post. its up to the site posted to, to check the source of the post and decide what to do with the data.user557846
@sapiensgladio - no, you can post anywhere you want. Cross-domain restrictions are about making it impossible for a script served from domain A to secretly get (possibly privileged) data from domain B.timdev
@Dagon27, add your comment as an answer - I will check as resolve. Thanks, I guess I was just confused.sapiensgladio

4 Answers

4
votes

POSTing a Form to any URL on the internet is never a problem. It doesn't matter if it's on the same domain or a different domain.

You can set up a contact form on your Shopify store and have it send a POST request to any URL where your custom application is listening to.

So the short answer is: This is absolutely no issue, just go ahead and add the form to your shop!

Some confusion on the topic might be caused by "Cross Domain AJAX". If you're doing your POST requests via Javascript then yes, it is only possible to do so if the target URL is on the same domain as the source that is sending the request. See also http://snook.ca/archives/javascript/cross_domain_aj

Hope this clears this up!

0
votes

No, you can't just use a CNAME in most cases. The CNAME will forward to the target server and if it's using virtual hosting, it uses the domain name to figure out how to handle the request. If they have it set up so the server only uses one domain name, it may be set up without a virtual host, which will allow this to work, but you don't really want your script to be dependent upon their server setup.

If you need to have it look like your url, I'd just put it inside a frame.

0
votes

A form can POST to any destination on the internet that the user's browser has access to.

0
votes

you don't need a cname, if you can set up a html form you can post it to any url on the net
...
post is a standard http header, you cant really have a webserver and it not accept post. its up to the site posted to, to check the source of the post and decide what to do with the data