Skip to content

InertiaRails Controller after action no cookie causes error #109

Open
@EamonIndigoSpark

Description

@EamonIndigoSpark

In the after_action I get an error, where the cookie is null:

require_relative "inertia_rails"
require_relative "helper"

module InertiaRails
module Controller
extend ActiveSupport::Concern

included do
  before_action do
    # :inertia_errors are deleted from the session by the middleware
    InertiaRails.share(errors: session[:inertia_errors]) if session[:inertia_errors].present?
  end
  helper ::InertiaRails::Helper

  after_action do
    cookies['XSRF-TOKEN'] = form_authenticity_token unless request.inertia? || !protect_against_forgery?
  end
end

cookies['XSRF-TOKEN'] = form_authenticity_token unless request.inertia? || !protect_against_forgery?

Resulting in this error

undefined method `[]=' for nil:NilClass

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions