Plugin Assets won't load (Kirby Routes on Nginx)

This one is bugging the crap out of me.

I’ve just cloned the StarterKit and created the following StarterKit/site/plugins/design/assets/js/test.js

Then I’ve fired up the php server php -S localhost:8000

When navigating to http://localhost:8000/assets/design/js/test.js I’m getting an 404 ? :pensive:

Your URL doesn’t contain /plugins. It has to be the following:

http://localhost:8000/assets/plugins/design/js/test.js

You can read more about plugin assets in the docs.

Hi Lukas,

Sorry, that was literally a misformed or rather midway edited copy/paste error :laughing:

But still http://localhost:8000/assets/plugins/design/js/test.js throws me an 404 ?

Does this really work for you? :confused:

I’ve tried everything, name my assets after my plugin etc.

It definitely worked with Apache when I tested it. I don’t know if it works with the PHP dev server.

Which kind of 404 do you get? One from the server or “The file could not be found” from Kirby? Or maybe even the normal Kirby error page?

The 404 I’m getting is PHP branded, normally i’m using nginx, but as I couldn’t get it to work there either I just tried a fresh StarterKit and the PHP server.

I will look more into this, to see what’s going on and whats needed in terms of the server config which prevent this stuff from working.

It has something to do with my server config, simple routes like 'pattern' => 'test.txt' works fine for me, but when it comes to sweet parameter stuff like 'pattern' => 'test/(:any)/(:all)' things gets all out of wack.

Okay so I have now solved this properly.

In my nginx config I was only using try_files IN the root instead of FROM the root, like so:

location / {
    autoindex off;
    try_files $uri $uri/ /index.php?$uri&$args;
}

Of cause had to be this

location ~ / {
    autoindex off;
    try_files $uri $uri/ /index.php?$uri&$args;
}

also location /panel should probably be location ~ /panel

Also see https://gist.github.com/bastianallgeier/c2e1f1e519f5f2943ec4#gistcomment-1795907

2 Likes