diff --git a/.replit b/.replit new file mode 100644 index 0000000..b4962bb --- /dev/null +++ b/.replit @@ -0,0 +1,38 @@ +modules = ["web", "nodejs-20"] +[agent] +expertMode = true + +[nix] +channel = "stable-25_05" + +[workflows] +runButton = "Project" + +[[workflows.workflow]] +name = "Project" +mode = "parallel" +author = "agent" + +[[workflows.workflow.tasks]] +task = "workflow.run" +args = "Start application" + +[[workflows.workflow]] +name = "Start application" +author = "agent" + +[[workflows.workflow.tasks]] +task = "shell.exec" +args = "cd backend && npm start" +waitForPort = 5000 + +[workflows.workflow.metadata] +outputType = "webview" + +[[ports]] +localPort = 5000 +externalPort = 80 + +[deployment] +deploymentTarget = "autoscale" +run = ["bash", "-c", "cd backend && npm start"] diff --git a/backend/server.js b/backend/server.js index f3303fe..d607982 100644 --- a/backend/server.js +++ b/backend/server.js @@ -1,16 +1,65 @@ const express = require('express'); const cors = require('cors'); +const path = require('path'); +const crypto = require('crypto'); require('dotenv').config(); const app = express(); +app.set('trust proxy', true); // Middleware app.use(cors()); app.use(express.json()); app.use(express.urlencoded({ extended: true })); +app.post('/.wf_graphql/csrf', (req, res) => { + const token = crypto.randomBytes(16).toString('hex'); + res.cookie('wf-csrf', token, { + httpOnly: false, + sameSite: 'lax', + secure: req.secure, + }); + res.status(204).send(); +}); + +app.post(['/.wf_graphql/apollo', '/.wf_graphql/usys/apollo'], (req, res) => { + res.json({ + data: { + database: { + id: 'local', + commerceOrder: { + comment: null, + extraItems: [], + id: 'local-cart', + startedOn: null, + statusFlags: { + hasDownloads: false, + hasSubscription: false, + isFreeOrder: false, + requiresShipping: false, + }, + subtotal: { decimalValue: '0', string: '$0.00', unit: 'USD', value: 0 }, + total: { decimalValue: '0', string: '$0.00', unit: 'USD', value: 0 }, + updatedOn: null, + userItems: [], + userItemsCount: 0, + }, + }, + site: { + commerce: { + id: 'local-commerce', + businessAddress: { country: 'US' }, + defaultCountry: 'US', + defaultCurrency: 'USD', + quickCheckoutEnabled: false, + }, + }, + }, + }); +}); + // Serve static files from the root directory -app.use(express.static('../')); +app.use(express.static(path.join(__dirname, '..'))); // Basic route app.get('/', (req, res) => { @@ -42,6 +91,7 @@ app.use((req, res) => { // Start server const PORT = process.env.PORT || 5000; -app.listen(PORT, () => { - console.log(`Server running on port ${PORT}`); +const HOST = process.env.HOST || '0.0.0.0'; +app.listen(PORT, HOST, () => { + console.log(`Server running on http://${HOST}:${PORT}`); }); diff --git a/company.html b/company.html index 5e690d3..fe3b136 100644 --- a/company.html +++ b/company.html @@ -15,6 +15,8 @@ +