diff --git a/src/api/challenges/challenges.service.ts b/src/api/challenges/challenges.service.ts index 30c82cb..3112965 100644 --- a/src/api/challenges/challenges.service.ts +++ b/src/api/challenges/challenges.service.ts @@ -7,7 +7,7 @@ import { orderBy, uniqBy, } from 'lodash'; -import { ConflictException, Injectable } from '@nestjs/common'; +import { BadRequestException, ConflictException, Injectable } from '@nestjs/common'; import { isUUID } from 'class-validator'; import { ENV_CONFIG } from 'src/config'; import { Logger } from 'src/shared/global'; @@ -66,9 +66,7 @@ export class ChallengesService { throw new BadRequestException('Invalid challengeId provided! Uuid expected!'); } - // Use the URL constructor to avoid path traversal/SSRF risks. - const baseUrl = TC_API_BASE.endsWith('/') ? TC_API_BASE.slice(0, -1) : TC_API_BASE; - const requestUrl = new URL(`/challenges/${challengeId}`, baseUrl).toString(); + const requestUrl = `${TC_API_BASE}/challenges/${challengeId}`; try { const challenge = await this.m2MService.m2mFetch(requestUrl);