× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



By the way it sounds like you are calling the node service from the client. Is that necessary? If so you could use web sockets. But why not route the call through your web app and have it call the node service (like a proxy)?

On 27 Jan 2018, at 09:35, Kevin <kevin@xxxxxxxxxxxxxx> wrote:

Which means it’s the same host - no?

On 26 Jan 2018, at 18:36, Justin Taylor <JUSTIN@xxxxxxxxxxxxx> wrote:

It looks like req.url contains a forward slash and the query string from the URL, but not the hostname.


From: Justin Taylor
Sent: Monday, January 15, 2018 12:40 PM
To: OpenSource-Midrange. com (opensource@xxxxxxxxxxxx) <opensource@xxxxxxxxxxxx>
Subject: Node Access-Control-Allow-Origin

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:
res.writeHead(200, {
'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



TIA
--
This is the IBMi Open Source Roundtable (OpenSource) mailing list
To post a message email: OpenSource@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: https://lists.midrange.com/mailman/listinfo/opensource
or email: OpenSource-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at https://archive.midrange.com/opensource.

--
This is the IBMi Open Source Roundtable (OpenSource) mailing list
To post a message email: OpenSource@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: https://lists.midrange.com/mailman/listinfo/opensource
or email: OpenSource-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at https://archive.midrange.com/opensource.


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 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 [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.