diff --git a/.github/workflows/generators.yml b/.github/workflows/generators.yml index 7c8e5ae8..23fa7219 100644 --- a/.github/workflows/generators.yml +++ b/.github/workflows/generators.yml @@ -25,7 +25,7 @@ jobs: tailwind: [true, false] ruby: ['3.3'] node: ['22'] - inertia_version: ['1.2.0', 'next', 'beta'] + inertia_version: ['1.2.0', '1.3', '2.0'] exclude: # 1.2.0 does not support typescript - typescript: true diff --git a/docs/guide/csrf-protection.md b/docs/guide/csrf-protection.md index e882de31..92c59414 100644 --- a/docs/guide/csrf-protection.md +++ b/docs/guide/csrf-protection.md @@ -57,6 +57,9 @@ Axios automatically checks for the existence of an `XSRF-TOKEN` cookie. If it's The easiest way to implement this is using server-side middleware. Simply include the `XSRF-TOKEN` cookie on each response, and then verify the token using the `X-XSRF-TOKEN` header sent in the requests from axios. (That's basically what `inertia_rails` does). +> [!NOTE] +> `X-XSRF-TOKEN` header only works for [Inertia requests](/guide/the-protocol#inertia-responses). If you want to send a normal request you can use `X-CSRF-TOKEN` instead. + ## Handling mismatches When a CSRF token mismatch occurs, Rails raises the `ActionController::InvalidAuthenticityToken` error. Since that isn't a valid Inertia response, the error is shown in a modal. diff --git a/lib/generators/inertia/install/install_generator.rb b/lib/generators/inertia/install/install_generator.rb index 6eca99eb..7686a164 100644 --- a/lib/generators/inertia/install/install_generator.rb +++ b/lib/generators/inertia/install/install_generator.rb @@ -78,8 +78,7 @@ def install_inertia template 'initializer.rb', file_path('config/initializers/inertia_rails.rb') say 'Installing Inertia npm packages' - add_dependencies(*FRAMEWORKS[framework]['packages']) - add_dependencies(inertia_package) + add_dependencies(inertia_package, *FRAMEWORKS[framework]['packages']) unless File.read(vite_config_path).include?(FRAMEWORKS[framework]['vite_plugin_import']) say "Adding Vite plugin for #{framework}" diff --git a/lib/generators/inertia/install/templates/react/InertiaExample.tsx b/lib/generators/inertia/install/templates/react/InertiaExample.tsx index 8c9886c8..b5061b03 100644 --- a/lib/generators/inertia/install/templates/react/InertiaExample.tsx +++ b/lib/generators/inertia/install/templates/react/InertiaExample.tsx @@ -18,7 +18,7 @@ export default function InertiaExample({ name }: { name: string }) {