Set-Cookie header in rails 7 wrongly set as array

248 views Asked by At

So, i recently created a rails 7.1 application and came about this weird thing: the headers are not properly set. It looks like the Set-Cookie header instead of getting repeated for every element of the cookies array it gets appended once and its value is the array of cookies itself, weirdly in the form of:

["_myapp_session

as key and the rest as value.

Is there a way to even debug this? how would i go about fixing it?

NGINX conf:

server {
  #listen [::]:443 ssl ipv6only=on;
  listen 443 ssl;
  ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem;
  ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;
  include /etc/letsencrypt/options-ssl-nginx.conf;
  ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;

  server_name example.com;
  root /home/path/to/app/public;

  passenger_enabled on;
  passenger_app_env production;

  location /cable {
    passenger_app_group_name myapp_websocket;
    passenger_force_max_concurrent_requests_per_process 0;
  }

  client_max_body_size 100m;

  location ~ ^/(assets|packs) {
    expires max;
    gzip_static on;
  }
}
server {
  if ($host = example.com) {
    return 301 https://$host$request_uri;
  }

  listen 80;
  listen [::]:80;

  server_name example.com;
  return 404;
}

server {
  listen 80;
  listen [::]:80;

  listen 443 ssl;
  listen [::]:443 ssl;

  server_name www.example.com;
  return 301 https://example.com;
}

ruby 3.0.2 rails 7.1.1 nginx + passengers

1

There are 1 answers

0
jukra On

Passenger is not yet compatible with Rack 3, you can downgrade to Rack 2 while keep using Rails 7.1 by adding this to your Gemfile:

gem "rack", "< 3"

You can also wait for new version of Passenger to be released (6.0.19) that adds support for Rack 3 header array (https://github.com/phusion/passenger/blob/b4c3921de29b3fa6aaa0d300fb06df67f12df698/CHANGELOG#L3)