Navigation

  • Recent
  • Tags
  • Users
  • Search
  • Login
Colyseus
  • Login
  • Search
  • Recent
  • Tags
  • Users

Documentation GitHub

We're migrating to GitHub Discussions. This forum does not accept new registrations since April 6, 2023.
  1. Home
  2. linlarr
  3. Posts
  • Profile
  • More
    • Continue chat with linlarr
    • Flag Profile
    • Following
    • Followers
    • Topics
    • Posts
    • Best
    • Groups

Posts made by linlarr

RE: Connecting to server from another domain

Hi @endel, thanks! That's all it was. Thanks also for pointing out the code.

posted in Questions & Help • 10 Sept 2019, 23:08
Connecting to server from another domain

Hi, I am trying to connect to my game server from another domain. When they are both on localhost I'm fine.

My server has code like this:

const express = require("express");
const app = express();
app.use(function(req, res, next) {
    res.setHeader("Access-Control-Allow-Origin", "https://client.github.io");
    res.setHeader("Access-Control-Allow-Methods", "GET, POST, PUT, DELETE");
    res.setHeader("Access-Control-Allow-Headers", "Content-Type");
    res.setHeader("Access-Control-Allow-Credentials", true);
    next();
});
const gameServer = new Server({
    server: createServer(app),
    express: app
});
// define room
const port = process.env.GAMEPORT || 5000;

My client connection code is something like:

const config = {gameServer : "wss://my-server.herokuapp.com:5000"};
client = new Colyseus.Client(config.gameServer);
// client creates room

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 https://my-server.herokuapp.com:5000/matchmake/create/gameRoom. (Reason: CORS request did not succeed). On Chrome and Firefox, I don't even get the response headers of what is allowed, though.

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).

Any help or pointers to resources would be much appreciated!

posted in Questions & Help • 10 Sept 2019, 21:13

© 2023 Endel Dreyer