Skip to content

Custom CSS using Nova::style on sail - file not found #3499

@powellblyth

Description

@powellblyth
  • Laravel Version:8.53.0
  • Nova Version: 3.28.0
  • Sail Version: v1.9.0
  • PHP Version:PHP 8.0.8 (cli) (built: Jul 1 2021 15:27:21) ( NTS )
  • Database Driver & Version: MariaDB
  • Operating System and Version: Sail on Mac (Intel)
  • Browser type and version: Any
  • Reproduction Repository: https://github.com/###/###

Description:

I'm running Nova on Sail, and I wanted to add a custom button colour.
I followed @davidhemphill 's video up to 1:20 to try and get any css file to show
https://www.youtube.com/watch?v=InK-mRH9z5M&t=85s
However, http://localhost:6080/nova-api/styles/elasticutNova gives me

ErrorException
file_get_contents(http://localhost:6080/css/elasticutNova.css): Failed to open stream: Cannot assign requested address

However, from my browser, I can access this URL http://localhost:6080/css/elasticutNova.css just fine

I think it's to do with PHP inside Sail trying to access the external address using file_get_contents, and failing, because it's obviously not a docker address

this is from vendor/laravel/nova/src/Http/Controllers/StyleController.php:28

public function show(NovaRequest $request)
    {
        $path = Arr::get(Nova::allStyles(), $request->style);
        abort_if(is_null($path), 404);
        return response(
            file_get_contents($path),
            200,
            [
                'Content-Type' => 'text/css',
            ]
        )->setLastModified(DateTime::createFromFormat('U', (string) filemtime($path)));
    }

Detailed steps to reproduce the issue on a fresh Nova installation:

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions