Laravel-apidoc-generator: static assets 404

Created on 8 Oct 2018  路  13Comments  路  Source: mpociot/laravel-apidoc-generator

When I use standard laravel serve command php artisan serve --port=8050 and go to http://127.0.0.1:8050/docs, I get 404 error for static assets like http://127.0.0.1:8050/css/style.css

Most helpful comment

As @goldengecko mentioned: My static assets returned 404 errors at http://127.0.0.1:5001/docs/ but everything worked fine at http://127.0.0.1:5001/docs/index.html.

All 13 comments

Can you double check that the URL being linked to in the HTML is actually http://127.0.0.1:8050/css/style.css?

This is generated index.html
image

This is my browser
image

what am I doing wrong?

Do these files exist in the public/docs folder?

image

but http://127.0.0.1:8050/docs/css/style.css works as expected

curl -I http://127.0.0.1:8050/docs/css/style.css
HTTP/1.1 200 OK
Host: 127.0.0.1:8050
Date: Mon, 08 Oct 2018 17:47:37 +0000
Connection: close
Content-Type: text/css; charset=UTF-8
Content-Length: 11894

It works this way
<link rel="stylesheet" href="/docs/css/style.css" /> <script src="/docs/js/all.js"></script>

Hey...I just remembered you don't need to serve your app to view the docs.
They're static assets, like you pointed out鈥擧TML and CSS. Just open the
index.html in a browser.

Hey...I just remembered you don't need to serve your app to view the docs. They're static assets, like you pointed out鈥擧TML and CSS. Just open the index.html in a browser.

shalvah, thank you! But how to serve this files in order to show to my frontend developer?

I don't understand your question... Just visit the path to the index.html
and open in your browser.

Ok, thanks!

How can I solve this problem? I also encountered it.

Since the normal rewrite rule is like this:

    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]

It will rewrite everything into your laravel application unless it's an actual real file. Since the documentation generator generates the index.html file and by default puts it in the /docs folder, if you go to /docs/index.html on your server it should work, whereas if you tried to go to /docs it would try to route the resource requests through your laravel app and not find them. HTH.

As @goldengecko mentioned: My static assets returned 404 errors at http://127.0.0.1:5001/docs/ but everything worked fine at http://127.0.0.1:5001/docs/index.html.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

arikardnoir picture arikardnoir  路  8Comments

Humni picture Humni  路  6Comments

yakabay picture yakabay  路  3Comments

ashokTagtaste picture ashokTagtaste  路  8Comments

usamaa picture usamaa  路  5Comments