Skip to content

Commit

Permalink
feat: change webui to be a https client
Browse files Browse the repository at this point in the history
  • Loading branch information
Meng-20 committed Jan 16, 2025
1 parent eab49a3 commit 387eb83
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 6 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,5 @@ webui/src/axios
/cmd/cxl-host/cxl-host-accounts.json

# Ignore the module files
webui/node_modules/
webui/node_modules/
webui/incoming/
16 changes: 16 additions & 0 deletions webui/generate-cert.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Copyright (c) 2025 Seagate Technology LLC and/or its Affiliates

#!/bin/bash

# Define certificate file paths
KEY_FILE="incoming/key.pem"
CERT_FILE="incoming/cert.pem"

# Create the directory if it doesn't exist
mkdir -p incoming

# Generate self-signed certificate
openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout $KEY_FILE -out $CERT_FILE -subj "/CN=localhost"

echo "Self-signed certificate generated: $CERT_FILE"
echo "Private key generated: $KEY_FILE"
4 changes: 2 additions & 2 deletions webui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
"version": "1.x.x",
"private": true,
"scripts": {
"dev": "vite",
"build": "vue-tsc --noEmit && vite build",
"dev": "sh generate-cert.sh && vite",
"build": "vue-tsc --noEmit && sh generate-cert.sh && vite build",
"preview": "vite preview",
"lint": "eslint . --fix --ignore-path .gitignore"
},
Expand Down
11 changes: 8 additions & 3 deletions webui/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import fs from 'fs';
// Utilities
import { defineConfig } from 'vite'
import { fileURLToPath, URL } from 'node:url'
import path from 'path';


const configYaml = fs.readFileSync('./config.yaml', 'utf8');
Expand Down Expand Up @@ -36,10 +37,10 @@ export default defineConfig({
},
}),
],
define: {
define: {
'process.env': {
BASE_PATH: parsedConfig.api.base_path,
}
}
},
resolve: {
alias: {
Expand All @@ -56,7 +57,11 @@ export default defineConfig({
],
},
server: {
host:'0.0.0.0',
host: '0.0.0.0',
port: 3000,
https: {
key: fs.existsSync(path.resolve(__dirname, 'incoming/key.pem')) ? fs.readFileSync(path.resolve(__dirname, 'incoming/key.pem')) : undefined,
cert: fs.existsSync(path.resolve(__dirname, 'incoming/cert.pem')) ? fs.readFileSync(path.resolve(__dirname, 'incoming/cert.pem')) : undefined
},
},
})

0 comments on commit 387eb83

Please sign in to comment.