Last active
October 18, 2025 11:06
-
-
Save rubywai/bd4ed24902cdeb0b699bc51d87d767b9 to your computer and use it in GitHub Desktop.
flutter_web_server_with_nodejs
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
| const express = require("express"); | |
| const path = require("path"); | |
| const app = express(); | |
| const port = process.env.PORT || 3000; | |
| const buildPath = path.join(__dirname, "web"); | |
| // Serve static files first | |
| app.use(express.static(buildPath)); | |
| // Fallback for all routes | |
| app.get(/.*/, (req, res) => { | |
| res.sendFile(path.join(buildPath, "index.html")); | |
| }); | |
| app.listen(port, () => { | |
| console.log(`🚀 Server running at http://localhost:${port}`); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment