diff --git a/backend/src/bundles/public-video/public-video.controller.ts b/backend/src/bundles/public-video/public-video.controller.ts index d8b95bab..18df8604 100644 --- a/backend/src/bundles/public-video/public-video.controller.ts +++ b/backend/src/bundles/public-video/public-video.controller.ts @@ -20,24 +20,30 @@ class PublicVideoController extends BaseController { this.addRoute({ path: PublicVideosApiPath.ROOT, - method: HTTPMethod.GET, - handler: (options) => this.findUrlByToken(options), + method: HTTPMethod.POST, + handler: (options) => { + return this.findUrlByToken( + options as ApiHandlerOptions<{ + body: { id: string }; + }>, + ); + }, }); } private async findUrlByToken( - options: ApiHandlerOptions, + options: ApiHandlerOptions<{ + body: { id: string }; + }>, ): Promise { // eslint-disable-next-line no-console - console.log(options, 'options'); - const headers = options.headers as Record; - const videoTokenHeader = headers['video_token']?.toString() ?? ''; + console.log(options.body, 'options.body'); + const jwt = options.body.id; // eslint-disable-next-line no-console - console.log(videoTokenHeader); + console.log(jwt, 'jwt'); return { status: HTTPCode.OK, - payload: - await this.publicVideoService.findUrlByToken(videoTokenHeader), + payload: await this.publicVideoService.findUrlByToken(jwt), }; } } diff --git a/backend/src/bundles/public-video/public-video.service.ts b/backend/src/bundles/public-video/public-video.service.ts index 05e4640c..de6d3b1c 100644 --- a/backend/src/bundles/public-video/public-video.service.ts +++ b/backend/src/bundles/public-video/public-video.service.ts @@ -11,20 +11,8 @@ class PublicVideoService { } // eslint-disable-next-line @typescript-eslint/no-explicit-any - public async findUrlByToken(token: any): Promise { - let id; - - // eslint-disable-next-line no-console - console.log(token, 'find url by token'); - if (token.id) { - id = token.id; - // eslint-disable-next-line no-console - console.log('id from token', id); - } else { - id = await tokenService.getIdFromToken(token); - // eslint-disable-next-line no-console - console.log('id from else', id); - } + public async findUrlByToken(token: string): Promise { + const id = await tokenService.getIdFromToken(token); if (!id) { this.throwVideoNotFoundError(); diff --git a/frontend/src/bundles/common/api/public-video-api/public-videos-api.ts b/frontend/src/bundles/common/api/public-video-api/public-videos-api.ts index c242cea4..99028d91 100644 --- a/frontend/src/bundles/common/api/public-video-api/public-videos-api.ts +++ b/frontend/src/bundles/common/api/public-video-api/public-videos-api.ts @@ -17,17 +17,13 @@ class PublicVideosApi extends BaseHttpApi { } public async getVideoUrlFromJWT(jwt: string): Promise { - const headers = new Headers(); - headers.append('video_token', jwt.replaceAll('~', '.')); - - // eslint-disable-next-line no-console - console.log('headers', headers.get('video_token')); + const updatedJwt = jwt.replaceAll('~', '.'); const options = { - method: HTTPMethod.GET, + method: HTTPMethod.POST, contentType: ContentType.JSON, hasAuth: true, - customHeaders: headers, + payload: JSON.stringify({ id: updatedJwt }), }; const response = await this.load(