Laravel JS files return 404 with correct content

I have a Laravel project installed on a server.
In this project I have some PHP generated JS files.
So I have created a route like js-localization/file.js, which refers to a laravel controller.
Locally this works fine, also on the production website (which is created and deployed using ploi) this works without any problem.

But here, I get a 404 error on the file, but the when I follow the URL, the file has the correct content.
I’ve never had an issue like this before and I have no idea what the problem could be here.

Strange thing is, when I put an exit in the controller, it doesn’t have any effect which leads me to think the controller is not called at all.
Also, the file does not exist physically.

I’ve attached one screenshot (not allowed more since I’m new here) that hopefully will help clarify my problem.

Okay so I’ve found the problem in the nginx configuration:

    location ~* \.(gif|jpg|jpeg|png|css|js)$ {
        expires max;
    }

Changed to:

    location ~* \.(gif|jpg|jpeg|png|css)$ {
       expires max;
    }

And now it works.
That leads me to the next question; is there any way to setup an nginx template like this so that I don’t have to remove it for every site I deploy?

Interesting. We ourselves do multiple deployments of a fairly large Laravel app (https::/feedmas.com) and has never run into this issue. Thanks for bringing it to our attention.

For the nginx template, this is on our backlog but now I’m bumping the priority since there is a good reason to have it now. Thanks again.