mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
feat(ui): handle proxy configs rewriting paths
We can't assume that the base URL is `host:port/` - it could be `host:port/some/path/`. Make the path handling dynamic to account for this.
This commit is contained in:
parent
e59954f956
commit
fc448d5b6d
@ -45,7 +45,7 @@ export const useSocketIO = () => {
|
|||||||
const socketOptions = useMemo(() => {
|
const socketOptions = useMemo(() => {
|
||||||
const options: Partial<ManagerOptions & SocketOptions> = {
|
const options: Partial<ManagerOptions & SocketOptions> = {
|
||||||
timeout: 60000,
|
timeout: 60000,
|
||||||
path: '/ws/socket.io',
|
path: `${window.location.pathname}ws/socket.io`,
|
||||||
autoConnect: false, // achtung! removing this breaks the dynamic middleware
|
autoConnect: false, // achtung! removing this breaks the dynamic middleware
|
||||||
forceNew: true,
|
forceNew: true,
|
||||||
};
|
};
|
||||||
|
@ -32,7 +32,7 @@ if (import.meta.env.MODE === 'package') {
|
|||||||
fallbackLng: 'en',
|
fallbackLng: 'en',
|
||||||
debug: false,
|
debug: false,
|
||||||
backend: {
|
backend: {
|
||||||
loadPath: '/locales/{{lng}}.json',
|
loadPath: `${window.location.href.replace(/\/$/, '')}/locales/{{lng}}.json`,
|
||||||
},
|
},
|
||||||
interpolation: {
|
interpolation: {
|
||||||
escapeValue: false,
|
escapeValue: false,
|
||||||
|
@ -57,7 +57,9 @@ const dynamicBaseQuery: BaseQueryFn<
|
|||||||
const projectId = $projectId.get();
|
const projectId = $projectId.get();
|
||||||
|
|
||||||
const rawBaseQuery = fetchBaseQuery({
|
const rawBaseQuery = fetchBaseQuery({
|
||||||
baseUrl: `${baseUrl ?? ''}/api/v1`,
|
baseUrl: baseUrl
|
||||||
|
? `${baseUrl}/api/v1`
|
||||||
|
: `${window.location.href.replace(/\/$/, '')}/api/v1`,
|
||||||
prepareHeaders: (headers) => {
|
prepareHeaders: (headers) => {
|
||||||
if (authToken) {
|
if (authToken) {
|
||||||
headers.set('Authorization', `Bearer ${authToken}`);
|
headers.set('Authorization', `Bearer ${authToken}`);
|
||||||
|
@ -26,8 +26,9 @@ export const receivedOpenAPISchema = createAsyncThunk(
|
|||||||
'nodes/receivedOpenAPISchema',
|
'nodes/receivedOpenAPISchema',
|
||||||
async (_, { rejectWithValue }) => {
|
async (_, { rejectWithValue }) => {
|
||||||
try {
|
try {
|
||||||
const url = [window.location.origin, 'openapi.json'].join('/');
|
const response = await fetch(
|
||||||
const response = await fetch(url);
|
`${window.location.href.replace(/\/$/, '')}/openapi.json`
|
||||||
|
);
|
||||||
const openAPISchema = await response.json();
|
const openAPISchema = await response.json();
|
||||||
|
|
||||||
const schemaJSON = JSON.parse(
|
const schemaJSON = JSON.parse(
|
||||||
|
Loading…
Reference in New Issue
Block a user