I'm trying to call a Node webservice from an existing app running on Apache. It's giving me problems because the app is running on a different port than Node. I did some searching, and I was able to get it to work by adding a new property to my header response:
'Content-Type' : 'application/json'
, 'Access-Control-Allow-Origin' : 'http://myHostName:80
' // Added this line
The trouble is that I have multiple production and test Apache servers, and I don't want to hardcode them all. They all have the same hostname, but I can't find a way to do a wildcard for the port#. What I got from Google, was to manually match against the calling host. If it matches, simply parrot it back for the Access-Control-Allow-Origin. The example I found returns null for me for the calling host. Here's what I found:
console.log(url.parse(req.url, true).host); //should return 'myHostName:80', but I get null
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2022 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.