0

I am coding using Laravel Framework 10.1.5 with github codespaces.

I am starting the server with php artisan serve and when I want to load a css-file in my blade view I am using <link href="{{ asset('fonts/google-font/css.css') }}" rel="stylesheet">.

However, this link is resolved to: <link href="http://localhost/fonts/google-font/css.css" rel="stylesheet">

My codespace url looks like that: https://githubUser-legendary-goggles-vp4432qvj12xsas32y234-8000.preview.app.github.dev/

Hence, my css file does not load.

I using a devcontainer and here is my configuration:

// See https://aka.ms/vscode-remote/devcontainer.json for format details.
{
    "name": "codespaces-laravel",
    "dockerComposeFile": ["docker-compose.yml"],
    "workspaceFolder": "/workspace",
    "service": "app",
    "shutdownAction": "stopCompose",
    "extensions": [
        "editorconfig.editorconfig",
        "ryannaddy.laravel-artisan",
        "amiralizadeh9480.laravel-extra-intellisense",
        "stef-k.laravel-goto-controller",
        "codingyu.laravel-goto-view",
        "mikestead.dotenv",
        "eg2.tslint",
        "christian-kohler.path-intellisense",
        "esbenp.prettier-vscode",
        "CoenraadS.bracket-pair-colorizer"
    ],
    "settings": {
        "#terminal.integrated.shell.linux": "/bin/bash"
    },
    // Use 'forwardPorts' to make a list of ports inside the container available locally.
    "forwardPorts": [80],

    // Use 'postCreateCommand' to run commands after the container is created.
    "postCreateCommand": "cp .env.example .env && composer install && php artisan key:generate && yarn install && yarn run development",
    "portsAttributes": {
        "80": {
            "label": "HTTP"
        }
    }
}

Any suggestion how to

Carol.Kar
  • 4,581
  • 36
  • 131
  • 264

1 Answers1

3

The asset helper prepends your ASSET_URL, defined in the .env file.

You can update your ASSET_URL to point to your website URL https://githubUser-legendary-goggles-vp4432qvj12xsas32y234-8000.preview.app.github.dev/ in your .env file.

https://laravel.com/docs/10.x/helpers#method-asset

Devon Bessemer
  • 34,461
  • 9
  • 69
  • 95