Skip to content

Instantly share code, notes, and snippets.

@rubywai
Last active October 18, 2025 11:06
Show Gist options
  • Select an option

  • Save rubywai/bd4ed24902cdeb0b699bc51d87d767b9 to your computer and use it in GitHub Desktop.

Select an option

Save rubywai/bd4ed24902cdeb0b699bc51d87d767b9 to your computer and use it in GitHub Desktop.
flutter_web_server_with_nodejs
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