• 1 Post
  • 4 Comments
Joined 11 months ago
cake
Cake day: October 29th, 2023

help-circle
  • In that situation, we can configure Nginx to route requests accordingly. We can set it up to forward requests with a path starting with “/api” to our Node.js application, and route all other requests to our Next.js application.
    server {
    listen 80;
    # Redirect /api requests to Node.js
    location /api {
    proxy_pass http://127.0.0.1:3001; # Assuming your Node.js app is running on port 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;
    }
    location / {
    proxy_pass http://127.0.0.1:3000; # Assuming your Next.js app is running on port 3000
    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;
    }
    }