get ingress to play nice with vite

This commit is contained in:
Blake Blackshear
2022-05-19 07:31:02 -05:00
parent 7b2b5bfa71
commit ca7bad8909
6 changed files with 12 additions and 10 deletions

View File

@@ -1,2 +1,2 @@
import { API_HOST } from '../env';
export const baseUrl = API_HOST || `${window.location.protocol}//${window.location.host}${window.baseUrl || ''}`;
export const baseUrl = API_HOST || `${window.location.protocol}//${window.location.host}${window.baseUrl || '/'}`;

View File

@@ -4,7 +4,7 @@ import useSWR, { SWRConfig } from 'swr';
import { MqttProvider } from './mqtt';
import axios from 'axios';
axios.defaults.baseURL = `${baseUrl}/api/`;
axios.defaults.baseURL = `${baseUrl}api/`;
export function ApiProvider({ children, options }) {
return (

View File

@@ -34,7 +34,7 @@ export function MqttProvider({
config,
children,
createWebsocket = defaultCreateWebsocket,
mqttUrl = `${baseUrl.replace(/^http/, 'ws')}/ws`,
mqttUrl = `${baseUrl.replace(/^http/, 'ws')}ws`,
}) {
const [state, dispatch] = useReducer(reducer, initialState);
const wsRef = useRef();