<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Connecting to server from another domain]]></title><description><![CDATA[<p>Hi, I am trying to connect to my game server from another domain. When they are both on localhost I'm fine.</p>
<p>My server has code like this:</p>
<pre><code>const express = require(&quot;express&quot;);
const app = express();
app.use(function(req, res, next) {
    res.setHeader(&quot;Access-Control-Allow-Origin&quot;, &quot;https://client.github.io&quot;);
    res.setHeader(&quot;Access-Control-Allow-Methods&quot;, &quot;GET, POST, PUT, DELETE&quot;);
    res.setHeader(&quot;Access-Control-Allow-Headers&quot;, &quot;Content-Type&quot;);
    res.setHeader(&quot;Access-Control-Allow-Credentials&quot;, true);
    next();
});
const gameServer = new Server({
    server: createServer(app),
    express: app
});
// define room
const port = process.env.GAMEPORT || 5000;
</code></pre>
<p>My client connection code is something like:</p>
<pre><code>const config = {gameServer : &quot;wss://my-server.herokuapp.com:5000&quot;};
client = new Colyseus.Client(config.gameServer);
// client creates room
</code></pre>
<p>But when I try to run this, the OPTIONS request gets blocked, with firefox console giving me the message that request is blocked, reading remote resource at <a href="https://my-server.herokuapp.com:5000/matchmake/create/gameRoom" rel="nofollow">https://my-server.herokuapp.com:5000/matchmake/create/gameRoom</a>. (Reason: CORS request did not succeed). On Chrome and Firefox, I don't even get the response headers of what is allowed, though.</p>
<p>I find this weird because I was able to successfully make https requests from the client using axios to the same server (had to not specify port though).</p>
<p>Any help or pointers to resources would be much appreciated!</p>
]]></description><link>http://discuss.colyseus.io/topic/289/connecting-to-server-from-another-domain</link><generator>RSS for Node</generator><lastBuildDate>Fri, 15 May 2026 04:38:42 GMT</lastBuildDate><atom:link href="http://discuss.colyseus.io/topic/289.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 10 Sep 2019 21:13:46 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Connecting to server from another domain on Tue, 10 Sep 2019 21:14:16 GMT]]></title><description><![CDATA[<p>Hi, I am trying to connect to my game server from another domain. When they are both on localhost I'm fine.</p>
<p>My server has code like this:</p>
<pre><code>const express = require(&quot;express&quot;);
const app = express();
app.use(function(req, res, next) {
    res.setHeader(&quot;Access-Control-Allow-Origin&quot;, &quot;https://client.github.io&quot;);
    res.setHeader(&quot;Access-Control-Allow-Methods&quot;, &quot;GET, POST, PUT, DELETE&quot;);
    res.setHeader(&quot;Access-Control-Allow-Headers&quot;, &quot;Content-Type&quot;);
    res.setHeader(&quot;Access-Control-Allow-Credentials&quot;, true);
    next();
});
const gameServer = new Server({
    server: createServer(app),
    express: app
});
// define room
const port = process.env.GAMEPORT || 5000;
</code></pre>
<p>My client connection code is something like:</p>
<pre><code>const config = {gameServer : &quot;wss://my-server.herokuapp.com:5000&quot;};
client = new Colyseus.Client(config.gameServer);
// client creates room
</code></pre>
<p>But when I try to run this, the OPTIONS request gets blocked, with firefox console giving me the message that request is blocked, reading remote resource at <a href="https://my-server.herokuapp.com:5000/matchmake/create/gameRoom" rel="nofollow">https://my-server.herokuapp.com:5000/matchmake/create/gameRoom</a>. (Reason: CORS request did not succeed). On Chrome and Firefox, I don't even get the response headers of what is allowed, though.</p>
<p>I find this weird because I was able to successfully make https requests from the client using axios to the same server (had to not specify port though).</p>
<p>Any help or pointers to resources would be much appreciated!</p>
]]></description><link>http://discuss.colyseus.io/post/976</link><guid isPermaLink="true">http://discuss.colyseus.io/post/976</guid><dc:creator><![CDATA[linlarr]]></dc:creator><pubDate>Tue, 10 Sep 2019 21:14:16 GMT</pubDate></item><item><title><![CDATA[Reply to Connecting to server from another domain on Invalid Date]]></title><description><![CDATA[<p>Hi <a class="plugin-mentions-user plugin-mentions-a" href="http://discuss.colyseus.io/uid/510">@linlarr</a>, which version of Colyseus are you using in the server-side?</p>
<p>You shouldn't need to manually set the &quot;Access-Control&quot; headers, since colyseus already does it for you: <a href="https://github.com/colyseus/colyseus/blob/master/src/Server.ts#L139-L150" rel="nofollow">https://github.com/colyseus/colyseus/blob/master/src/Server.ts#L139-L150</a></p>
]]></description><link>http://discuss.colyseus.io/post/977</link><guid isPermaLink="true">http://discuss.colyseus.io/post/977</guid><dc:creator><![CDATA[endel]]></dc:creator><pubDate>Invalid Date</pubDate></item><item><title><![CDATA[Reply to Connecting to server from another domain on Invalid Date]]></title><description><![CDATA[<p>Maybe the problem is because you're requesting <code>herokuapp.com:5000</code>. Heroku only opens up the ports <code>80</code>/<code>443</code>. Anything other than that will be refused.</p>
]]></description><link>http://discuss.colyseus.io/post/978</link><guid isPermaLink="true">http://discuss.colyseus.io/post/978</guid><dc:creator><![CDATA[endel]]></dc:creator><pubDate>Invalid Date</pubDate></item><item><title><![CDATA[Reply to Connecting to server from another domain on Invalid Date]]></title><description><![CDATA[<p>Hi <a class="plugin-mentions-user plugin-mentions-a" href="http://discuss.colyseus.io/uid/1">@endel</a>, thanks! That's all it was. Thanks also for pointing out the code.</p>
]]></description><link>http://discuss.colyseus.io/post/979</link><guid isPermaLink="true">http://discuss.colyseus.io/post/979</guid><dc:creator><![CDATA[linlarr]]></dc:creator><pubDate>Invalid Date</pubDate></item></channel></rss>