Changelog - 2026-11-06 β
CORS origin patterns accept π for any port, such as http://localhostπ β
New Feature SecurityIn one line. configs.middlewares.cors.origin takes :* as the port of a pattern, so "http://localhost on any port" is one entry and an app no longer keeps its own origin function for it.
What changed β
- Any port.
http://localhost:*,http://127.0.0.1:*andhttps://*.example.com:*match the host on any port and with no port. - Still exact where it matters. The scheme must be equal. The host is exact for
http://localhost:*, and forhttps://*.example.com:*it follows the subdomain rules (the apex does not match).http://localhost.evil.com:3000andhttp://sub.localhost:3000do not matchhttp://localhost:*. - A real port number. What follows the colon in the request must be a number from 1 to 65535 with no leading zero;
http://localhost:abcandhttp://localhost:3000@evil.comdo not match. - Refused at boot.
http://*:*,http://local*:*,http://[::1]:*(IPv6 is not supported) and any other shape stop the application from starting with a message naming the pattern. A port written as a number keeps matching exactly.
typescript
middlewares: {
cors: {
origin: ['http://localhost:*', 'http://127.0.0.1:*', 'https://*.example.com'],
},
},Who is affected β
- Apps that wrote an origin function for "localhost on any port". They can switch to the pattern.
- Everyone else. No action needed. A pattern without
:*behaves as before.
WARNING
http://localhost:* lets any page served from any port on the visitor's own machine call your API. Keep it out of a production configuration.
Details β
| File | Package |
|---|---|
src/base/applications/cors.ts | kernel |
src/base/applications/common/types/middlewares.ts | kernel |