-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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
aeb3ec8
commit 3d03899
Showing
4 changed files
with
46 additions
and
3 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