Github代码空间Laravel 10服务器css

ttp71kqs  于 2023-03-09  发布在  Git
关注(0)|答案(1)|浏览(96)

我正在使用带有github代码空间的Laravel Framework 10.1.5进行编码。
我使用php artisan serve启动服务器,当我想在我的刀片视图中加载css-file时,我使用<link href="{{ asset('fonts/google-font/css.css') }}" rel="stylesheet">
但是,此链接解析为:<link href="http://localhost/fonts/google-font/css.css" rel="stylesheet">
我的代码空间URL看起来像这样:https://githubUser-legendary-goggles-vp4432qvj12xsas32y234-8000.preview.app.github.dev/
因此,我的css文件没有加载。
我使用的是devcontainer,下面是我的配置:

// 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"
        }
    }
}

有什么建议吗

z2acfund

z2acfund1#

资源辅助对象预先添加在.env文件中定义的ASSET_URL
您可以更新您的ASSET_URL以指向您的.env文件中的网站URL https://githubUser-legendary-goggles-vp4432qvj12xsas32y234-8000.preview.app.github.dev/
https://laravel.com/docs/10.x/helpers#method-asset

相关问题