diff --git a/ecosystem.config.cjs b/ecosystem.config.cjs index 70e0d0c..ab8a16e 100644 --- a/ecosystem.config.cjs +++ b/ecosystem.config.cjs @@ -6,6 +6,8 @@ module.exports = { apps: [{ name: 'flyer-crawler-api', // The name of our application in PM2 + // Explicitly set the working directory. This is crucial for reliability. + cwd: '/var/www/flyer-crawler.projectium.com', script: 'npm', // The script to run (we want to run an npm command) args: 'run start', // The arguments to pass to the script (i.e., 'npm run start') env_production: { diff --git a/etc-nginx-sites-available-flyer-crawler.projectium.com b/etc-nginx-sites-available-flyer-crawler.projectium.com index b95a8d9..86fa048 100644 --- a/etc-nginx-sites-available-flyer-crawler.projectium.com +++ b/etc-nginx-sites-available-flyer-crawler.projectium.com @@ -20,6 +20,20 @@ server { try_files $uri $uri/ /index.html; } + # This new block is the reverse proxy for your backend API. + # It tells Nginx that any request starting with /api/ should be + # forwarded to your Node.js server running on port 3001. + location /api/ { + # The trailing slash on the proxy_pass URL is crucial. + # It tells Nginx to strip the `/api/` prefix from the request URI + # before passing it to the backend server. + proxy_pass http://localhost:3001/; + proxy_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection 'upgrade'; + proxy_set_header Host $host; + proxy_cache_bypass $http_upgrade; + } # This block specifically targets requests for .mjs files. location ~ \.mjs$ {