Fix express middleware and dev script loading mocks#1076
Merged
kentcdodds merged 2 commits intoepicweb-dev:mainfrom Jan 5, 2026
Merged
Fix express middleware and dev script loading mocks#1076kentcdodds merged 2 commits intoepicweb-dev:mainfrom
kentcdodds merged 2 commits intoepicweb-dev:mainfrom
Conversation
2 tasks
There was a problem hiding this comment.
Pull request overview
This PR fixes two regressions introduced in PR #1066 by correcting the middleware loading order and ensuring mocks are loaded before the development server starts.
Key Changes:
- Moved Vite/production middleware to load after all other Express middleware in
server/index.ts - Updated dev scripts to run
index.tsinstead ofserver/index.tsto ensure mocks are loaded first
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| server/index.ts | Moved the Vite dev server and production middleware block from immediately after app creation to after all other middleware (HTTPS redirect, trailing slash removal, compression, helmet, rate limiting, etc.), ensuring proper middleware execution order |
| package.json | Updated dev and dev:no-mocks scripts to run index.ts instead of server/index.ts, making them consistent with the start scripts and ensuring mocks are loaded before the server starts |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The following PR caused 2 regressions:
#1066
Test Plan
The middleware is now loaded before the dev server starts. You can test this by running
npm run devand go tolocalhost:3000/login/and see that it redirects tolocalhost:300/login/now.The mocks of index.ts are now loaded correctly. You can test this by going to
npm run devand see the message🔶 Mock server installedin the console.Checklist
Screenshots