Skip to content

Commit

Permalink
fix: CORS not being set for assets (#30237)
Browse files Browse the repository at this point in the history
  • Loading branch information
sampaiodiego committed Aug 31, 2023
1 parent 8a59855 commit 761cad4
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/shiny-garlics-carry.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@rocket.chat/meteor': patch
---

Fix CORS headers not being set for assets
2 changes: 1 addition & 1 deletion apps/meteor/app/cors/server/cors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ WebApp.rawConnectHandlers.use((_req: http.IncomingMessage, res: http.ServerRespo
const _staticFilesMiddleware = WebAppInternals.staticFilesMiddleware;

// @ts-expect-error - accessing internal property of webapp
WebAppInternals._staticFilesMiddleware = function (
WebAppInternals.staticFilesMiddleware = function (
staticFiles: StaticFiles,
req: http.IncomingMessage,
res: http.ServerResponse,
Expand Down
17 changes: 17 additions & 0 deletions apps/meteor/tests/end-to-end/api/32-assets.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { describe, it } from 'mocha';

import { request } from '../../data/api-data.js';

describe('assets', function () {
this.retries(0);

it('should always have CORS headers for assets', async () => {
await request.get('/assets/favicon.svg').expect('Content-Type', 'image/svg+xml').expect('Access-Control-Allow-Origin', '*').expect(200);

await request
.get('/fonts/rocketchat.woff2')
.expect('Content-Type', 'font/woff2')
.expect('Access-Control-Allow-Origin', '*')
.expect(200);
});
});

0 comments on commit 761cad4

Please sign in to comment.