Skip to content

Unable to Access Swagger UI Assets via Nginx #648

@sandipanUipl

Description

@sandipanUipl

When using Nginx to serve a Laravel application, the Swagger UI assets (like swagger-ui.css, swagger-ui-bundle.js, etc.) are not automatically placed in the public directory after running the php artisan vendor:publish --provider "L5Swagger\L5SwaggerServiceProvider" command.

For proper integration with Nginx, these assets need to be publicly accessible. However, the vendor:publish command doesn't place them in the public/vendor directory by default, which results in 404 errors when trying to access Swagger UI.

Steps to Reproduce:

Install the L5 Swagger package via Composer in a Laravel project.

Run the following command to publish the resources:

php artisan vendor:publish --provider "L5Swagger\L5SwaggerServiceProvider"

Verify that the assets (e.g., swagger-ui.css, swagger-ui-bundle.js) are not published to the public/vendor directory.

Attempt to access Swagger UI in the browser.

Nginx returns 404 errors because the assets aren't found.

Expected Behavior:

The Swagger UI assets should be publicly accessible in the public/vendor directory, so they can be served correctly by Nginx. However, they are not automatically published with the vendor:publish command.

Actual Behavior:

The assets are not automatically published to the public/vendor directory, causing Nginx to return 404 errors when trying to load the Swagger UI assets.

Possible Solution:

Manual Asset Publishing: Since the assets aren't published by default, it would be helpful if the documentation or package provided clear instructions for publishing them manually to the public/vendor directory. This can be done by copying the relevant files from the vendor directory (e.g., vendor/swagger-api/swagger-ui/dist/) to public/vendor/swagger-api/swagger-ui/.

Automation Option: Ideally, the php artisan vendor:publish command should include an option (or tag) that automatically publishes the Swagger UI assets to the public/vendor directory, making them accessible via Nginx.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions