File tree Expand file tree Collapse file tree 4 files changed +52
-0
lines changed
Expand file tree Collapse file tree 4 files changed +52
-0
lines changed Original file line number Diff line number Diff line change 33.nuxt /
44.nitro /
55.cache /
6+ certificates /
67dist /
78node_modules /
89.DS_Store /
Original file line number Diff line number Diff line change @@ -4,6 +4,12 @@ APPNAME?=sesame-app-manager
44APP_PORT? =3002
55PLATFORM? =linux/amd64
66
7+ CERT_DIR = ./certificates
8+ COMMON_NAME = localhost
9+ DAYS_VALID = 365
10+
11+ $(shell mkdir -p $(CERT_DIR))
12+
713.DEFAULT_GOAL := help
814help :
915 @printf " \033[33mUsage:\033[0m\n make [target] [arg=\" val\" ...]\n\n\033[33mTargets:\033[0m\n"
4955 -e NODE_ENV=development \
5056 -v $(CURDIR ) :/data \
5157 $(IMGNAME ) bash
58+
59+ generate-ssl-cert : # # Générer les certificats HTTPS auto-signés
60+ @echo " Génération des certificats HTTPS auto-signés..."
61+ @openssl req -x509 \
62+ -newkey rsa:4096 \
63+ -keyout $(CERT_DIR ) /server.key \
64+ -out $(CERT_DIR ) /server.crt \
65+ -days $(DAYS_VALID ) \
66+ -nodes \
67+ -subj " /CN=$( COMMON_NAME) "
68+ @chmod 600 $(CERT_DIR ) /server.key
69+ @chmod 644 $(CERT_DIR ) /server.crt
70+ @echo " Certificats générés avec succès dans $( CERT_DIR) "
71+
72+ clean-ssl-cert : # # Nettoyer les certificats HTTPS
73+ @rm -rf $(CERT_DIR )
74+ @echo " Certificats supprimés"
75+
76+ show-cert-info : # # Afficher les informations du certificat
77+ @openssl x509 -in $(CERT_DIR ) /server.crt -text -noout
Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ import pugPlugin from 'vite-plugin-pug'
44import openapiTS from 'openapi-typescript'
55import { defineNuxtConfig } from 'nuxt/config'
66import { parse } from 'yaml'
7+ import consola from 'consola'
78
89const SESAME_APP_API_URL = process . env . SESAME_APP_API_URL || 'http://localhost:4002'
910
@@ -16,6 +17,19 @@ if (process.env.SESAME_APP_DARK_MODE) {
1617 }
1718}
1819
20+ let https = { }
21+ if ( / y e s | 1 | o n | t r u e / i. test ( `${ process . env . SESAME_HTTPS_ENABLED } ` ) ) {
22+ try {
23+ https = {
24+ key : readFileSync ( `${ process . env . SESAME_HTTPS_PATH_KEY } ` , 'utf8' ) ,
25+ cert : readFileSync ( `${ process . env . SESAME_HTTPS_PATH_CERT } ` , 'utf8' ) ,
26+ } ;
27+ consola . info ( '[Nuxt] SSL certificates loaded successfully' )
28+ } catch ( error ) {
29+ consola . warn ( '[Nuxt] Error while reading SSL certificates' , error )
30+ }
31+ }
32+
1933// https://nuxt.com/docs/api/configuration/nuxt-config
2034export default defineNuxtConfig ( {
2135 ssr : false ,
@@ -25,6 +39,7 @@ export default defineNuxtConfig({
2539 debug : ! ! process . env . DEBUG ,
2640 devServer : {
2741 port : 3000 ,
42+ https,
2843 } ,
2944 devtools : {
3045 enabled : process . env . NODE_ENV === 'development' ,
Original file line number Diff line number Diff line change @@ -51,6 +51,16 @@ function buildNuxt() {
5151}
5252
5353; ( async ( ) => {
54+ if ( / y e s | 1 | o n | t r u e / i. test ( `${ process . env . SESAME_HTTPS_ENABLED } ` ) ) {
55+ try {
56+ process . env . NITRO_SSL_KEY = readFileSync ( `${ process . env . SESAME_HTTPS_PATH_KEY } ` , 'utf8' )
57+ process . env . NITRO_SSL_CERT = readFileSync ( `${ process . env . SESAME_HTTPS_PATH_CERT } ` , 'utf8' )
58+ consola . info ( '[Nuxt] SSL certificates loaded successfully' )
59+ } catch ( error ) {
60+ consola . warn ( '[Nuxt] Error while reading SSL certificates' , error )
61+ }
62+ }
63+
5464 if ( hashEnv ( ) !== readHash ( ) ) {
5565 consola . warn ( 'Hash changed, rebuilding...' )
5666 consola . info ( `Hash: ${ hashEnv ( ) } , Previous: ${ readHash ( ) } ` )
You can’t perform that action at this time.
0 commit comments