File tree Expand file tree Collapse file tree 1 file changed +10
-2
lines changed
packages/convex-helpers/server Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -81,14 +81,22 @@ export type CorsConfig = {
81
81
debug ?: boolean ;
82
82
} ;
83
83
84
- type RouteSpecWithCors = RouteSpec & CorsConfig ;
84
+ export type RouteSpecWithCors = RouteSpec & CorsConfig ;
85
+
86
+ /**
87
+ * An HttpRouter with built in cors support.
88
+ */
89
+ export type CorsHttpRouter = {
90
+ http : HttpRouter
91
+ route : ( routeSpec : RouteSpecWithCors ) => void ;
92
+ } ;
85
93
86
94
/**
87
95
* Factory function to create a router that adds CORS support to routes.
88
96
* @param allowedOrigins An array of allowed origins for CORS.
89
97
* @returns A function to use instead of http.route when you want CORS.
90
98
*/
91
- export const corsRouter = ( http : HttpRouter , corsConfig ?: CorsConfig ) => {
99
+ export const corsRouter = ( http : HttpRouter , corsConfig ?: CorsConfig ) : CorsHttpRouter => {
92
100
const allowedExactMethodsByPath : Map < string , Set < string > > = new Map ( ) ;
93
101
const allowedPrefixMethodsByPath : Map < string , Set < string > > = new Map ( ) ;
94
102
return {
You can’t perform that action at this time.
0 commit comments