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 = {
8181 debug ?: boolean ;
8282} ;
8383
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+ } ;
8593
8694/**
8795 * Factory function to create a router that adds CORS support to routes.
8896 * @param allowedOrigins An array of allowed origins for CORS.
8997 * @returns A function to use instead of http.route when you want CORS.
9098 */
91- export const corsRouter = ( http : HttpRouter , corsConfig ?: CorsConfig ) => {
99+ export const corsRouter = ( http : HttpRouter , corsConfig ?: CorsConfig ) : CorsHttpRouter => {
92100 const allowedExactMethodsByPath : Map < string , Set < string > > = new Map ( ) ;
93101 const allowedPrefixMethodsByPath : Map < string , Set < string > > = new Map ( ) ;
94102 return {
You can’t perform that action at this time.
0 commit comments