Skip to content

Commit

Permalink
Merge pull request #427 from BinaryStudioAcademy/task/OV-426-fix-sockets
Browse files Browse the repository at this point in the history
OV-426: * vite config
  • Loading branch information
anton-otroshchenko authored Sep 25, 2024
2 parents bf43477 + 6a93f63 commit e4aa255
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions frontend/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ VITE_APP_API_ORIGIN_URL=/api/v1
# DEV
#
VITE_APP_PROXY_SERVER_URL=http://localhost:3001
VITE_APP_SOCKET_ORIGIN_URL=/socket.io
3 changes: 3 additions & 0 deletions frontend/src/framework/config/base-config.package.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ class BaseConfig implements Config {
ORIGIN_URL: import.meta.env[
'VITE_APP_API_ORIGIN_URL'
] as string,
SOCKET_ORIGIN_URL: import.meta.env[
'VITE_APP_SOCKET_ORIGIN_URL'
] as string,
},
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ type EnvironmentSchema = {
};
API: {
ORIGIN_URL: string;
SOCKET_ORIGIN_URL: string;
};
};

Expand Down
6 changes: 6 additions & 0 deletions frontend/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const config = ({ mode }: ConfigEnv): ReturnType<typeof defineConfig> => {
VITE_APP_DEVELOPMENT_PORT,
VITE_APP_API_ORIGIN_URL,
VITE_APP_PROXY_SERVER_URL,
VITE_APP_SOCKET_ORIGIN_URL,
} = loadEnv(mode, process.cwd());

return defineConfig({
Expand Down Expand Up @@ -56,6 +57,11 @@ const config = ({ mode }: ConfigEnv): ReturnType<typeof defineConfig> => {
target: VITE_APP_PROXY_SERVER_URL,
changeOrigin: true,
},
[VITE_APP_SOCKET_ORIGIN_URL as string]: {
target: VITE_APP_PROXY_SERVER_URL,
changeOrigin: true,
ws: true,
},
},
},
resolve: {
Expand Down

0 comments on commit e4aa255

Please sign in to comment.