Laravel5.6 dynamically generates js files and returns 404.

problem description

because I"m going to do SPA web. So you need a dynamic configuration file
, for example, I want to: xxx.com/setter.js

Environment
Server: ngnix
php:7.2.6
laravel:5.6

related codes

routing settings

(function(root,factroy){
    typeof root.xxxx === "object" ? xxxx.setter = factroy() :
    root.setter = factroy();
}(this,function(){
    return {
        name:"xxx",
        csrf:"{{ csrf_token() }}"
    };
}));

actual situation

what is returned in the src of script is 404, and there is no content.
returns 404 in the href of link:css, with no content.
returns 404 in the src of img, with content.
address bar access returns 404, with content.

I"m really drunk.

Mar.28,2021

if you just want to complete the csrf_token, you can put the generated token on a global variable or on an element. When you want to use it, you can just take it


it seems to be the only way for now.

Menu