fix: use relative /api URL to prevent mixed content errors on HTTPS

pull/10/head
root 2026-03-07 17:55:11 +01:00
parent fef33cc9be
commit 34daa301ed
6 changed files with 13 additions and 5 deletions

View File

@ -1,6 +1,6 @@
import axios from 'axios';
const API_BASE = import.meta.env.VITE_API_BASE || 'http://localhost:8001/api';
const API_BASE = import.meta.env.VITE_API_BASE || '/api';
const api = axios.create({ baseURL: API_BASE, withCredentials: true });

View File

@ -1,7 +1,7 @@
import axios from 'axios';
import type { UserResponse } from '../store/useAuthStore';
const API_BASE = import.meta.env.VITE_API_BASE || 'http://localhost:8001/api';
const API_BASE = import.meta.env.VITE_API_BASE || '/api';
const api = axios.create({ baseURL: API_BASE, withCredentials: true });

View File

@ -1,6 +1,6 @@
import axios from 'axios';
const API_BASE = import.meta.env.VITE_API_BASE || 'http://localhost:8001/api';
const API_BASE = import.meta.env.VITE_API_BASE || '/api';
export interface SketchFile {
name: string;

View File

@ -1,4 +1,4 @@
const API_BASE = `${import.meta.env.VITE_API_BASE || 'http://localhost:8001/api'}/libraries`;
const API_BASE = `${import.meta.env.VITE_API_BASE || '/api'}/libraries`;
export interface ArduinoLibrary {
name: string;

View File

@ -1,6 +1,6 @@
import axios from 'axios';
const API_BASE = import.meta.env.VITE_API_BASE || 'http://localhost:8001/api';
const API_BASE = import.meta.env.VITE_API_BASE || '/api';
const api = axios.create({ baseURL: API_BASE, withCredentials: true });

View File

@ -12,6 +12,14 @@ export default defineConfig({
'@wokwi/elements': path.resolve(__dirname, '../wokwi-libs/wokwi-elements/dist/esm'),
},
},
server: {
proxy: {
'/api': {
target: 'http://localhost:8001',
changeOrigin: true,
},
},
},
optimizeDeps: {
include: ['avr8js', 'rp2040js', '@wokwi/elements'],
},