mkcert icon indicating copy to clipboard operation
mkcert copied to clipboard

These files don't work for Nuxt

Open joezimjs opened this issue 2 years ago • 3 comments

I ran npx mkcert create-ca; npx mkcert create-cert, then tried to feed those certs to Nuxt's config: https://nuxt.com/docs/api/configuration/nuxt-config#https

If I run it using ca.key and ca.crt I get this in my browser (Vivaldi)

image

If I use cert.key and cert.crt, then I get the unsafe warning:

image

Am I using this output wrong?

joezimjs avatar Jul 09 '23 04:07 joezimjs

Can you also post your nuxt config? Looks like you are using ca.key and ca.cert instead of cert.key and cert.crt.

Subash avatar Jul 10 '23 03:07 Subash

I told you in my message that I tried both. The text between the pictures specifies that I tried cert.key and cert.crt and the 2nd picture shows what happens when I use those.

Here's my Nuxt config

import Inspector from 'unplugin-vue-inspector/vite';

// https://v3.nuxtjs.org/api/configuration/nuxt.config

const isProd = process.env.NODE_ENV === 'production';

export default defineNuxtConfig({
	extends: ['nuxt-seo-kit'],

	modules: [
		'@storyblok/nuxt',
		'@nuxtjs/tailwindcss'
		// 'nuxt-speedkit'
	],

	experimental: {
		componentIslands: true
	},

	components: [
		{
			path: '~/components/rich-text',
			global: true
		}
	],

	devServer: {
		https: {
			key: 'cert.key',
			cert: 'cert.crt'
		}
	},
	devtools: true,

	storyblok: {
		accessToken: process.env.STORYBLOK_TOKEN,
		apiOptions: {
			region: 'us',
			version: isProd ? 'published' : 'draft'
		},
		bridge: !isProd // optimizes by excluding the bridge on production
	},

	tailwindcss: {
		/* https://tailwindcss.nuxtjs.org/getting-started/options */
	},

	vite: {
		server: { https: true },
		plugins: [Inspector()]
	}
});

joezimjs avatar Jul 10 '23 13:07 joezimjs

I apologize for the misunderstanding. This package doesn't install the certificate to the system trust store automatically so you have to trust the certificate manually to make the warning go away.

Subash avatar Jul 12 '23 07:07 Subash