Skip to content

Commit

Permalink
fix: fix socket url
Browse files Browse the repository at this point in the history
  • Loading branch information
Manokii committed Oct 20, 2022
1 parent fffbc63 commit 4573acc
Show file tree
Hide file tree
Showing 8 changed files with 550 additions and 27 deletions.
1 change: 1 addition & 0 deletions apps/frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
"@vitejs/plugin-react": "2.1.0",
"typescript": "4.8.4",
"vite": "3.1.7",
"tsconfig": "*",
"vite-plugin-svgr": "2.2.1"
}
}
9 changes: 9 additions & 0 deletions apps/frontend/src/vite-env.d.ts
Original file line number Diff line number Diff line change
@@ -1 +1,10 @@
/// <reference types="vite/client" />

interface ImportMetaEnv {
readonly PROD: boolean;
// more env variables...
}

interface ImportMeta {
readonly env: ImportMetaEnv;
}
1 change: 1 addition & 0 deletions apps/frontend/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"compilerOptions": {},
"extends": "tsconfig/vite.json",
"include": ["."],
"exclude": ["dist", "build", "node_modules"],
Expand Down
11 changes: 9 additions & 2 deletions lib/ws-client/socket.instance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,16 @@ import { io } from "socket.io-client";
import { globalDispatch, setState } from "store/";
import { setChamps } from "store/redux.champs.slice";

const URL = `${window.location.hostname}:1338`;
const isDev = import.meta.env.DEV;
const DEV_URL = `${window.location.hostname}:1338`;
const PROD_URL = "https://servers.acadarena.com/wr";
const URL = isDev ? DEV_URL : PROD_URL;
const PATH = isDev ? "/socket.io" : "/wr/socket.io";

export const socket = io(URL);
export const socket = io({
host: URL,
path: PATH,
});

socket.on("state", (state: State) => {
globalDispatch(setState({ state }));
Expand Down
8 changes: 0 additions & 8 deletions lib/ws-client/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,4 @@
{
"compilerOptions": {
"target": "es2016" /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */,
"module": "commonjs" /* Specify what module code is generated. */,
"esModuleInterop": true /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables `allowSyntheticDefaultImports` for type compatibility. */,
"forceConsistentCasingInFileNames": true /* Ensure that casing is correct in imports. */,
"strict": true /* Enable all strict type-checking options. */,
"skipLibCheck": true /* Skip type checking all .d.ts files. */
},
"include": ["./"],
"extends": "tsconfig/vite.json"
}
9 changes: 9 additions & 0 deletions lib/ws-client/vite-env.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/// <reference types="vite/client" />

interface ImportMetaEnv {
readonly PROD: boolean;
}

interface ImportMeta {
readonly env: ImportMetaEnv;
}
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"devDependencies": {
"@commitlint/config-conventional": "17.1.0",
"commitizen": "4.2.5",
"commitlint": "17.1.2",
"cz-conventional-changelog": "3.3.0",
"eslint-config-custom": "*",
"husky": "8.0.1",
Expand Down
Loading

1 comment on commit 4573acc

@vercel
Copy link

@vercel vercel bot commented on 4573acc Oct 20, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.