surreal's avatar

"npm run hot" fails to receive “https://localhost:8080/js/app.js" in browser

I wanted to start learning vue.js. First of all I upgraded Laravel (Remoteserver) from 5.8 to 6 to 7 and finally 8.58.

  • Node v16.8
  • npm v7.21.1
  • added <script src="{{mix('js/app.js')}}"></script> to my blade

compiling via npm run dev and npm run prod seems to be working but I seem to recompile everything manually if I make any changes.

npm run hot compiles without any issues but my browser it fails seems fail getting /js/app.js.

Console: Loading failed for the <script> with source “https://localhost:8080/js/app.js”.

I removed node_modules folder, cleared the cache and reinstalled npm and mix several times. Nothing changed. I dont know what to do know. I'm pretty close to set up a complete new project and start reprogramming my site from scratch. My guess are missing dependencies because of some issues while updating laravel

Package.json:

    "private": true,
    "scripts": {
        "dev": "npm run development",
        "development": "mix",
        "watch": "mix watch",
        "watch-poll": "mix watch -- --watch-options-poll=1000",
        "hot": "mix watch --hot --https ",
        "prod": "npm run production",
        "production": "mix --production"
    },
    "devDependencies": {
        "axios": "^0.21",
        "cross-env": "^7.0.3",
        "laravel-mix": "^6.0.29",
        "lodash": "^4.17.19",
        "postcss": "^8.1.14",
        "resolve-url-loader": "^4.0.0",
        "sass": "^1.38.2",
        "sass-loader": "^12.1.0",
        "vue-loader": "^15.9.8",
        "vue-template-compiler": "^2.6.14"
    },
    "dependencies": {
        "bootstrap": "^5.1.0",
        "vue": "^2.6.14",
        "webpack": "^5.51.1",
        "webpack-cli": "^4.8.0"
    }
}

Composer.json

{
    "name": "laravel/laravel",
    "type": "project",
    "description": "The Laravel Framework.",
    "keywords": [
        "framework",
        "laravel"
    ],
    "license": "MIT",
    "require": {
        "php": "^8.0",
        "fabpot/goutte": "^4.0",
        "fideloper/proxy": "^4.2",
        "laravel-notification-channels/pushover": "^3.0",
        "laravel/framework": "^8.0",
        "laravel/tinker": "^2.0",
        "laravel/ui": "^3.0",
        "guzzlehttp/guzzle": "^7.0.1"
    },
    "require-dev": {
        "beyondcode/laravel-dump-server": "^1.0",
        "filp/whoops": "^2.0",
        "fzaninotto/faker": "^1.4",
        "mockery/mockery": "^1.0",
        "nunomaduro/collision": "^5.0",
        "phpunit/phpunit": "^9.0",
        "facade/ignition": "^2.3.6"


    },
    "config": {
        "optimize-autoloader": true,
        "preferred-install": "dist",
        "sort-packages": true
    },
    "extra": {
        "laravel": {
            "dont-discover": []
        }
    },
    "autoload": {
        "psr-4": {
            "App\": "app/"
        },
        "classmap": [
            "database/seeds",
            "database/factories"
        ]
    },
    "autoload-dev": {
        "psr-4": {
            "Tests\": "tests/"
        }
    },
    "minimum-stability": "dev",
    "prefer-stable": true,
    "scripts": {
        "post-autoload-dump": [
            "Illuminate\Foundation\ComposerScripts::postAutoloadDump",
            "@php artisan package:discover --ansi"
        ],
        "post-root-package-install": [
            "@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
        ],
        "post-create-project-cmd": [
            "@php artisan key:generate --ansi"
        ]
    }
}
0 likes
3 replies
surreal's avatar

I guess I'm a step further. I disabled automatic redirections from http to https.

Now npm run hot actually seem to work when I'm visiting via http. I begin assume the entire project isn't meant to be on a live webserver.

Sinnbeck's avatar

No your arent supposed to use hot reloading on a live webserver. Hot reloading is for developing only.

akr4mkhan's avatar
const fs = require('fs')

//...

mix.js('resources/js/app.js', 'public/js')
    .postCss('resources/css/app.css', 'public/css', [
        //
    ])
    .options({
        hmrOptions: {
            host: 'mixhmrhttps.test',
            port: 8080
        }
    })
    .webpackConfig({
        devServer: {
            https: {
                key: fs.readFileSync('/Users/YOURUSERNAME/.config/valet/Certificates/mixhmrhttps.test.key'),
                cert: fs.readFileSync('/Users/YOURUSERNAME/.config/valet/Certificates/mixhmrhttps.test.crt')
            }
        }
    })

Please or to participate in this conversation.