Next.js Discord

Discord Forum

NextJS ServerActions through Nginx proxy

Unanswered
Japanese cockle posted this in #help-forum
Open in Discord
Japanese cockleOP
Hello, we are having troubles with our Nginx when trying to execute a server action.

The error is: Invalid Server Actions request

Our current nginx.config is as such:
worker_processes  1;
error_log  /dev/stdout;
pid        /tmp/nginx.pid;

events {
  worker_connections  4096;  ## Default: 1024
}

http {

  default_type application/octet-stream;
  log_format   main '$remote_addr - $remote_user [$time_local]  $status '
    '"$request" $body_bytes_sent "$http_referer" '
    '"$http_user_agent" "$http_x_forwarded_for"';
  access_log   /dev/stdout;

  server {
    listen       8080;
    server_name  localhost;

    ####### DEV ONLY
    # Discovery
    location ~* ^/admin {
      rewrite ^/(.*) /$1 break;
      proxy_pass      http://localhost:3030;
      proxy_redirect          off;
    }

    ####### ALL OTHER ROUTES TO NEXTJS
    location / {
      proxy_pass      http://localhost: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;
    }
  }
}


It seems to me that server actions is trying to use something we are not supporting in our config as it works when running localhost:3000 but not when running through the proxy - localhost:8080

I appreciate any help

0 Replies