Horizon: Retrying a failed job 419 response

Created on 1 Sep 2017  路  6Comments  路  Source: laravel/horizon

I have found that I can eventually retry all failed jobs after multiple page refreshes. However, I noticed that some retry attempts do not actually succeed after clicking the retry button. When I pulled up the web inspector, I found that these requests had a 419 unknown status response from the server with a response containing.

{
    "message": ""
}

I don't know the reason for this error (nginx, php 7.1, ubuntu 16.04), but some error handling on the retry button's axios request would at least allow a user to reattempt another retry if a 419 occurs without a full page refresh.

Most helpful comment

I know this is a closed and relatively old topic. But for me the solution was to disable the csrf token validation for the route horizon/* because I have the VerifyCsrfToken middleware in my web middleware group. A solution could be to define a different middleware group and set it in your config: horizon.middleware. Another solution is to skip csrf validation for the horizon/* routes:

VerifyCsrfToken.php

class VerifyCsrfToken extends Middleware
{
    /**
     * The URIs that should be excluded from CSRF verification.
     *
     * @var array
     */
    protected $except = [
        'horizon/*'
    ];

    // ... the rest
}

All 6 comments

Here's a gif too.

419 Oh my

I get the same 419 status message when I attempt to monitor a tag as well.

Can't replicate, retrying failed jobs as well as monitoring tags works fine for me.

I know this is a closed and relatively old topic. But for me the solution was to disable the csrf token validation for the route horizon/* because I have the VerifyCsrfToken middleware in my web middleware group. A solution could be to define a different middleware group and set it in your config: horizon.middleware. Another solution is to skip csrf validation for the horizon/* routes:

VerifyCsrfToken.php

class VerifyCsrfToken extends Middleware
{
    /**
     * The URIs that should be excluded from CSRF verification.
     *
     * @var array
     */
    protected $except = [
        'horizon/*'
    ];

    // ... the rest
}

I cause the same conflict and if I omit the csrf the same thing happens with the middleware of auth, I think it is a header in the configuration of nginx but not solution solution

This has been solved in Nova (https://github.com/laravel/nova-issues/issues/323) by adding default headers to Axios based on this piece of code document.head.querySelector('meta[name="csrf-token"]').content. I think it should be added here too. I'm having the issue as well after setting $addHttpCookie = false in VerifyCsrfToken.

This is also part of the Laravel bootstrap JS: https://github.com/laravel/laravel/blob/master/resources/js/bootstrap.js

Was this page helpful?
0 / 5 - 0 ratings

Related issues

rossuhms picture rossuhms  路  5Comments

etiennellipse picture etiennellipse  路  3Comments

marianvlad picture marianvlad  路  5Comments

Pustiu picture Pustiu  路  5Comments

crash13override picture crash13override  路  5Comments