remix
                                
                                 remix copied to clipboard
                                
                                    remix copied to clipboard
                            
                            
                            
                        feat(remix-express): remove dependency on `express`
This PR removes express as a dependency from the "express" handler (using only vanilla http module). This allows the handler to be used by any "express like" router (like polka) or using http.createServer directly! This should improve remix's compatibility with many node based http server frameworks.
Example (using http.createServer & sirv)
import * as http from 'http';
import * as path from 'path';
import sirv from 'sirv';
import { createRequestHandler } from '@remix-run/express';
const BUILD_DIR = path.join(process.cwd(), "build");
const remixHandler = createRequestHandler({ build: require(BUILD_DIR) });
const server = http.createServer(sirv("public", {
	  maxAge: 3600,
	  setHeaders(res, pathname) {
		    if (pathname.startsWith("/build/")) {
		      res.setHeader("Cache-Control", "public, max-age=31536000, immutable");
		    }
	  },
	  onNoMatch: remixHandler
}));
server.listen(process.env.PORT || 3000);
Closes: #
- [ ] Docs
- [ ] Tests
Testing Strategy:
All tests pass.
Hi @nicksrandall,
Welcome, and thank you for contributing to Remix!
Before we consider your pull request, we ask that you sign our Contributor License Agreement (CLA). We require this only once.
You may review the CLA and sign it by adding your name to contributors.yml.
Once the CLA is signed, the CLA Signed label will be added to the pull request.
If you have already signed the CLA and received this response in error, or if you have any questions, please contact us at [email protected].
Thanks!
- The Remix team
Thank you for signing the Contributor License Agreement. Let's get this merged! 🥳
⚠️ No Changeset found
Latest commit: 312f245f0c4abc22588e94235a433d94c3545b1e
Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.
This PR includes no changesets
When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types
Click here to learn what changesets are, and how to add one.
Click here if you're a maintainer who wants to add a changeset to this PR
Looks like this PR got borked a bit with some unrelated changes related to .node files in https://github.com/remix-run/remix/pull/3234/commits/f724f0aaeaff9bbd30c3d62360409217deb3e20a. Mind fixing those up so we can take a look?
This is the strangest thing but maybe I mixed up my PRs? This is code for a completely unrelated PR. Let me fix this.
@nicksrandall no worries, I've done the same 😅 Usually happens because you try to fix two issues on the same branch and accidentally end up force-pushing to the wrong one.
Closing in favor of #5237