vincent15000's avatar

Laravel / InertiaJS / VueJS - 502 Bad Gateway

Hello,

I'm working on an application with Laravel / InertiaJS / VueJS.

Locally all works fine, but in preproduction, I get an issue with some forms.

Instead of displaying the validation messages, I get a 502 Bad Gateway error.

Do you have any idea ?

What do you suggest me to check ?

Thanks for your help.

V

0 likes
5 replies
vincent15000's avatar

I just had a look at the nginx errors logs.

I get this error.

upstream sent too big header while reading response header from upstream

I don't understand how it can be possible.

The form is empty and I get this error.

When the form is correctly filled, I don't get any error.

JussiMannisto's avatar
Level 50

It may be caused by the asset preload headers set by Inertia. Together with other headers, they can exceed the default FastCGI buffer size of Nginx. You can try increasing the size in the http block in nginx.conf, e.g.

fastcgi_buffers 16 16k;
fastcgi_buffer_size 32k;

Then restart Nginx.

1 like
vincent15000's avatar

Ok thank you.

Hmmm ... in this case, I think that it would be better to use another session driver.

I have tried with file, it's ok it works.

With database it doesn't work.

I'm using Laravel, InertiaJS and VueJS.

Any idea ?

Thanks ;).

JussiMannisto's avatar

Why would your choice of session driver matter? Unless you use the cookie driver, it should make no difference whatsoever.

Nginx is telling you what's wrong: your backend (upstream) is sending response headers that are too big. Either increase the buffer size in Nginx or remove the AddLinkHeadersForPreloadedAssets middleware in Laravel. I don't recommend the latter if you care about performance.

1 like
vincent15000's avatar

Oh ... ok ... so there is no real difference between file and database ?

Please or to participate in this conversation.