-
-
Notifications
You must be signed in to change notification settings - Fork 6.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: allow CORS from loopback addresses by default (#19249)
- Loading branch information
1 parent
9df6e6b
commit 7d1699c
Showing
5 changed files
with
62 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { expect, test } from 'vitest' | ||
import { defaultAllowedOrigins } from '../constants' | ||
|
||
test('defaultAllowedOrigins', () => { | ||
const allowed = [ | ||
'http://localhost', | ||
'http://foo.localhost', | ||
'http://localhost:3000', | ||
'https://localhost:3000', | ||
'http://127.0.0.1', | ||
'http://[::1]', | ||
'http://[::1]:3000', | ||
] | ||
const denied = [ | ||
'file:///foo', | ||
'http://localhost.example.com', | ||
'http://foo.example.com:localhost', | ||
'http://', | ||
'http://192.0.2', | ||
'http://[2001:db8::1]', | ||
'http://vite', | ||
'http://vite:3000', | ||
] | ||
|
||
for (const origin of allowed) { | ||
expect(defaultAllowedOrigins.test(origin), origin).toBe(true) | ||
} | ||
|
||
for (const origin of denied) { | ||
expect(defaultAllowedOrigins.test(origin), origin).toBe(false) | ||
} | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters