@@ -854,17 +854,7 @@ export async function _createServer(
854854 } )
855855 }
856856
857- // apply server configuration hooks from plugins
858- const configureServerContext = new BasicMinimalPluginContext (
859- { ...basePluginContextMeta , watchMode : true } ,
860- config . logger ,
861- )
862- const postHooks : ( ( ( ) => void ) | void ) [ ] = [ ]
863- for ( const hook of config . getSortedPluginHooks ( 'configureServer' ) ) {
864- postHooks . push ( await hook . call ( configureServerContext , reflexServer ) )
865- }
866-
867- // Internal middlewares ------------------------------------------------------
857+ // Pre applied internal middlewares ------------------------------------------
868858
869859 // request timer
870860 if ( process . env . DEBUG ) {
@@ -887,6 +877,19 @@ export async function _createServer(
887877 middlewares . use ( hostValidationMiddleware ( allowedHosts , false ) )
888878 }
889879
880+ // apply configureServer hooks ------------------------------------------------
881+
882+ const configureServerContext = new BasicMinimalPluginContext (
883+ { ...basePluginContextMeta , watchMode : true } ,
884+ config . logger ,
885+ )
886+ const postHooks : ( ( ( ) => void ) | void ) [ ] = [ ]
887+ for ( const hook of config . getSortedPluginHooks ( 'configureServer' ) ) {
888+ postHooks . push ( await hook . call ( configureServerContext , reflexServer ) )
889+ }
890+
891+ // Internal middlewares ------------------------------------------------------
892+
890893 middlewares . use ( cachedTransformMiddleware ( server ) )
891894
892895 // proxy
@@ -934,7 +937,8 @@ export async function _createServer(
934937 middlewares . use ( htmlFallbackMiddleware ( root , config . appType === 'spa' ) )
935938 }
936939
937- // run post config hooks
940+ // apply configureServer post hooks ------------------------------------------
941+
938942 // This is applied before the html middleware so that user middleware can
939943 // serve custom content instead of index.html.
940944 postHooks . forEach ( ( fn ) => fn && fn ( ) )
0 commit comments