PR-824002: Using proxy instead of a redirect.

This commit is contained in:
2025-01-13 04:36:45 +00:00
parent 32eec62ad0
commit 4e45f0a04f
11 changed files with 197 additions and 106 deletions

View File

@ -1,24 +1,13 @@
import request from 'supertest';
import express from 'express';
import { setRoutes } from '../src/routes/index';
import dotenv from 'dotenv';
import app from '../src/app';
dotenv.config();
const app = express();
setRoutes(app);
describe('GET /', () => {
it('should redirect to CDN URL', async () => {
describe('Proxy Middleware', () => {
it('should proxy to CDN URL', async () => {
const response = await request(app).get('/');
expect(response.status).toBe(302);
expect(response.header.location).toBe(process.env.CDN_URL);
expect(response.status).toBe(200);
});
it('should return 500 if CDN URL is not configured', async () => {
process.env.CDN_URL = '';
const response = await request(app).get('/');
expect(response.status).toBe(500);
expect(response.text).toBe('CDN URL not configured');
});
});
});