diff --git a/back/volume/src/auth/mails/confirm.hbs b/back/volume/src/auth/mails/confirm.hbs index b96b493..fbcb9c5 100644 --- a/back/volume/src/auth/mails/confirm.hbs +++ b/back/volume/src/auth/mails/confirm.hbs @@ -10,6 +10,6 @@

Once you clicked on the next verify button, you will have access to the app

-
diff --git a/back/volume/src/chat/chat.gateway.ts b/back/volume/src/chat/chat.gateway.ts index 642ea03..fa262ce 100644 --- a/back/volume/src/chat/chat.gateway.ts +++ b/back/volume/src/chat/chat.gateway.ts @@ -14,12 +14,10 @@ import type Message from './entity/message.entity' import * as bcrypt from 'bcrypt' import { MessageService } from './message.service' import { CreateMessageDto } from './dto/create-message.dto' -import { InjectRepository } from '@nestjs/typeorm' -import { Repository } from 'typeorm' import { ConnectionDto } from './dto/connection.dto' @WebSocketGateway({ - cors: { origin: /^(http|ws):\/\/localhost(:\d+)?$/ } + cors: { origin: new RegExp(`^(http|ws)://${process.env.HOST ?? 'localhost'}(:\\d+)?$`) } }) export class ChatGateway implements OnGatewayConnection, OnGatewayDisconnect { @WebSocketServer() @@ -81,8 +79,7 @@ export class ChatGateway implements OnGatewayConnection, OnGatewayDisconnect { } @SubscribeMessage('addMessage') - async onAddMessage (message: CreateMessageDto): Promise { - console.log(JSON.stringify(message)) + async onAddMessage (socket: Socket, message: CreateMessageDto): Promise { const channel = await this.chatService.getChannel(message.ChannelId) if ( (await this.chatService.getMuteDuration(channel.id, message.UserId)) > 0 diff --git a/back/volume/src/main.ts b/back/volume/src/main.ts index 88efdea..2f9ab51 100644 --- a/back/volume/src/main.ts +++ b/back/volume/src/main.ts @@ -15,7 +15,7 @@ async function bootstrap (): Promise { ? +process.env.BACK_PORT : 3001 const cors = { - origin: /^(http|ws):\/\/localhost(:\d+)?$/, + origin: new RegExp(`^(http|ws)://${process.env.HOST ?? 'localhost'}(:\\d+)?$`), methods: 'GET, HEAD, PUT, PATCH, POST, DELETE, OPTIONS', preflightContinue: false, optionsSuccessStatus: 204, diff --git a/back/volume/src/pong/pong.gateway.ts b/back/volume/src/pong/pong.gateway.ts index f2df12b..a215346 100644 --- a/back/volume/src/pong/pong.gateway.ts +++ b/back/volume/src/pong/pong.gateway.ts @@ -22,7 +22,7 @@ import { PongService } from './pong.service' import { UsersService } from 'src/users/users.service' @WebSocketGateway({ - cors: { origin: /^(http|ws):\/\/localhost(:\d+)?$/ } + cors: { origin: new RegExp(`^(http|ws)://${process.env.HOST ?? 'localhost'}(:\\d+)?$`) } }) export class PongGateway implements OnGatewayConnection, OnGatewayDisconnect { constructor ( @@ -66,6 +66,7 @@ export class PongGateway implements OnGatewayConnection, OnGatewayDisconnect { ): Promise<{ event: string, data: boolean }> { let succeeded: boolean = false const user = await this.usersService.findUserByName(playerName.value) + console.log(socketKey.value, user?.socketKey) if ( user !== null && user.socketKey === socketKey.value && diff --git a/back/volume/src/users/users.controller.ts b/back/volume/src/users/users.controller.ts index 884f4b1..7cf4dba 100644 --- a/back/volume/src/users/users.controller.ts +++ b/back/volume/src/users/users.controller.ts @@ -102,7 +102,7 @@ export class UsersController { @Post('avatar') @UseGuards(AuthenticatedGuard) - @Redirect('http://localhost') + @Redirect(`http://${process.env.HOST ?? 'localhost'}`) @UseInterceptors( FileInterceptor('avatar', { storage: diskStorage({ diff --git a/front/volume/src/socket.ts b/front/volume/src/socket.ts index 9628bcf..0566811 100644 --- a/front/volume/src/socket.ts +++ b/front/volume/src/socket.ts @@ -1,3 +1,3 @@ import { io, Socket } from "socket.io-client"; -export const socket: Socket = io("http://localhost:3001"); +export const socket: Socket = io("http://" + (import.meta.env.VITE_HOST ?? 'localhost') + ":3001");