@@ -854,17 +854,7 @@ export async function _createServer(
854
854
} )
855
855
}
856
856
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 ------------------------------------------
868
858
869
859
// request timer
870
860
if ( process . env . DEBUG ) {
@@ -887,6 +877,19 @@ export async function _createServer(
887
877
middlewares . use ( hostValidationMiddleware ( allowedHosts , false ) )
888
878
}
889
879
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
+
890
893
middlewares . use ( cachedTransformMiddleware ( server ) )
891
894
892
895
// proxy
@@ -934,7 +937,8 @@ export async function _createServer(
934
937
middlewares . use ( htmlFallbackMiddleware ( root , config . appType === 'spa' ) )
935
938
}
936
939
937
- // run post config hooks
940
+ // apply configureServer post hooks ------------------------------------------
941
+
938
942
// This is applied before the html middleware so that user middleware can
939
943
// serve custom content instead of index.html.
940
944
postHooks . forEach ( ( fn ) => fn && fn ( ) )
0 commit comments