Friday, July 1, 2022
HomeWordPress DevelopmentHow you can make Vite, Valet, and SSL works collectively

How you can make Vite, Valet, and SSL works collectively


Hey 👋

I made a decision to create a brand new venture at this time, then I created a brand new laravel venture and it is coming with a brand new belongings compiler, vite.

However my venture requires SSL in native growth, then I wanted to make the vite works along with SSL and laravel valet.

I didn’t discover a lot content material on the web about it, as a result of it is a very new launch, then I made a decision to share the answer with you.

Let’s go, first guarantee your area have already got SSL with the command:

cd ~/Code/your-current-project
valet safe your-current-project
Enter fullscreen mode

Exit fullscreen mode

Now examine within the browser your area it is working with the certificates.



Resolution

The magic is you go the important thing and cert to vite.config.js as you make in Nginx or Apache.

Examine the file instance bellow 👇

import { defineConfig } from 'vite';
import laravel from 'laravel-vite-plugin';
import vue from '@vitejs/plugin-vue';

 const area = "area.take a look at"; // add it
 const homedir = require("os").homedir(); // add it

export default defineConfig({
    plugins: [
        laravel({
            input: "resources/js/app.js",
            ssr: "resources/js/ssr.js",
        }),
        vue({
            template: {
                transformAssetUrls: {
                    base: null,
                    includeAbsolute: false,
                },
            },
        }),
    ],
    // add this block
    server: {
        https: {
            key: homedir + "/.config/valet/Certificates/" + area + ".key",
            cert: homedir + "/.config/valet/Certificates/" + area + ".crt",
        },
        host: area,
        hmr: {
            host: area,
        },
    },
});
Enter fullscreen mode

Exit fullscreen mode

I hope this text helped you!

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments