diff --git a/server/Procfile b/server/Procfile new file mode 100644 index 0000000..5d978b6 --- /dev/null +++ b/server/Procfile @@ -0,0 +1,2 @@ +# Instruct Render to start the server from the src entrypoint +web: node src/index.js diff --git a/server/public/index.html b/server/public/index.html index ad1ea1b..8e75325 100644 --- a/server/public/index.html +++ b/server/public/index.html @@ -11,3 +11,4 @@

Welcome to Shield X

+ diff --git a/server/routes/auth.js b/server/routes/auth.js index 7506e55..bf86787 100644 --- a/server/routes/auth.js +++ b/server/routes/auth.js @@ -4,7 +4,6 @@ import jwt from 'jsonwebtoken'; import User from '../models/UserR.js'; import authMiddleware from '../middleware/authMiddleware.js'; - const router = express.Router(); // Register diff --git a/server/src/index.js b/server/src/index.js index 23f1981..f30a2bf 100644 --- a/server/src/index.js +++ b/server/src/index.js @@ -5,6 +5,7 @@ import connectDB from '../config/db.js'; import authRoutes from '../routes/auth.js'; import path from 'path'; import { fileURLToPath } from 'url'; +import axios from 'axios'; dotenv.config(); connectDB(); @@ -19,7 +20,9 @@ const PORT = process.env.PORT || 5000; app.use(express.json({ limit: '10mb' })); app.use(express.urlencoded({ extended: true, limit: '10mb' })); // Allow cross-origin requests during development (Vite runs on :5174) -app.use(cors()); +app.use(cors({ + origin: "*" +})); // serve public from project root (/server/public) app.use(express.static(path.join(__dirname, '..', 'public'))); app.use('/api', authRoutes); @@ -28,6 +31,12 @@ app.get('/', (req, res) => { res.sendFile(path.join(__dirname, '..', 'public', 'index.html')); }); +// Create an axios instance usable from the server. Use the Vite-style env name +// if present on the server, otherwise fall back to localhost. +const API = axios.create({ + baseURL: process.env.VITE_API_URL || "http://localhost:5000" +}); + app.listen(PORT, () => { console.log(`Server running on http://localhost:${PORT}`); });