How to deploy https and wss(solved)

Since we cannot edit index.ts when deploying on Arena, how to deploy on Arena while it listening to wss:url and https for matchmaking API?

Here is my attemp:

import Arena from "@colyseus/arena";
import { monitor } from "@colyseus/monitor";

import { RelayRoom } from "./rooms/RelayRoom";

const { createServer } = require("https")
const { key, cert } = require("./ssl")()
import { WebSocketTransport } from "@colyseus/ws-transport"
const express = require("express")
import cors from "cors";

export default Arena({
  getId: () => "Your Colyseus App",

  initializeGameServer: (gameServer) => {
    gameServer.define("gameroom", RelayRoom, {
      maxClients: 100,
      allowReconnectionTime: 0,
    });
  },

  
  initializeExpress: (app) => {
    /**
     * Bind your custom express routes here:
     */
    app.get("/", (req, res) => {
      res.send("It's time to kick ass and chew bubblegum!");
    });

    /**
     * Bind @colyseus/monitor
     * It is recommended to protect this route with a password.
     * Read more: https://docs.colyseus.io/tools/monitor/
     */
    app.use("/colyseus", monitor());
  },

  beforeListen: () => {
    /**
     * Before before gameServer.listen() is called.
     */
  },

  initializeTransport: (options) => {

    const app = express()
    app.use(cors());
    app.use(express.json())

    // Prepare HTTPS server
    const secureServer = createServer({ key, cert }, app)
    console.log("secureServer created")
    return new WebSocketTransport({
        server: secureServer,
    });
},

});

@xiao
Hi, will you please post in Chinese channel so I can get a better understand.

@coco
Hi, I cant post in Chinese.

My website is secure (https://domain.com), and I am hosting my game engine backend in Colyseus Arena (https://www.colyseus.io/arena), which is not secure (not https, not wss:), because I am following this documentations (https://docs.colyseus.io/arena/getting-started/create-colyseus-server/).

How do I change the Colyseus backend (hosted on Colyseus Arena), to be listening on https and wss?

My arena.config.js on the server doesn't host and listen in secure (https and wss):

import Arena from "@colyseus/arena";
import { monitor } from "@colyseus/monitor";

import { RelayRoom } from "./rooms/RelayRoom";

const { createServer } = require("https")
const { key, cert } = require("./ssl")()
import { WebSocketTransport } from "@colyseus/ws-transport"
const express = require("express")
import cors from "cors";

export default Arena({
  getId: () => "Your Colyseus App",

  initializeGameServer: (gameServer) => {
    gameServer.define("gameroom", RelayRoom, {
      maxClients: 100,
      allowReconnectionTime: 0,
    });
  },

  
  initializeExpress: (app) => {
    /**
     * Bind your custom express routes here:
     */
    app.get("/", (req, res) => {
      res.send("It's time to kick ass and chew bubblegum!");
    });

    /**
     * Bind @colyseus/monitor
     * It is recommended to protect this route with a password.
     * Read more: https://docs.colyseus.io/tools/monitor/
     */
    app.use("/colyseus", monitor());
  },

  beforeListen: () => {
    /**
     * Before before gameServer.listen() is called.
     */
  },

  initializeTransport: (options) => {

    const app = express()
    app.use(cors());
    app.use(express.json())

    // Prepare HTTPS server
    const secureServer = createServer({ key, cert }, app)
    console.log("secureServer created")
    return new WebSocketTransport({
        server: secureServer,
    });
},

});

Problem solved:

wss://yourid.colyseus.dev

Ah yes, it shows in here:
0_1647320605584_bcbc0a28-0e38-430c-98a0-e1ca81ffc254-image.png