Compare commits

...

2 Commits

Author SHA1 Message Date
DarkSky
ae4c201e40 fix: use secure websocket (#5297) 2023-12-14 11:28:25 +08:00
DarkSky
6724e5a537 feat: only follow serverUrlPrefix at redirect to client (#5295) 2023-12-14 11:28:09 +08:00
6 changed files with 26 additions and 19 deletions

View File

@@ -140,7 +140,9 @@ export const AffineSharePage = (props: ShareMenuProps) => {
lineHeight: '20px',
}}
value={
isSharedPage ? sharingUrl : `${runtimeConfig.serverUrlPrefix}/...`
isSharedPage
? sharingUrl
: `${location.protocol}//${location.hostname}/...`
}
readOnly
/>

View File

@@ -19,8 +19,11 @@ export const generateUrl = ({
// to generate a public url like https://affine.app/share/123/456
// or https://affine.app/share/123/456?mode=edgeless
const { protocol, hostname, port } = window.location;
const url = new URL(
`${runtimeConfig.serverUrlPrefix}/${urlType}/${workspaceId}/${pageId}`
`${protocol}//${hostname}${
port ? `:${port}` : ''
}/${urlType}/${workspaceId}/${pageId}`
);
return url.toString();
};

View File

@@ -17,8 +17,7 @@ export async function downloadBinaryFromCloud(
return cached;
}
const response = await fetchWithTraceReport(
runtimeConfig.serverUrlPrefix +
`/api/workspaces/${rootGuid}/docs/${pageGuid}`,
`/api/workspaces/${rootGuid}/docs/${pageGuid}`,
{
priority: 'high',
}

View File

@@ -19,9 +19,7 @@ import useSWRMutation from 'swr/mutation';
setupGlobal();
export const fetcher = gqlFetcherFactory(
runtimeConfig.serverUrlPrefix + '/graphql'
);
export const fetcher = gqlFetcherFactory('/graphql');
/**
* A `useSWR` wrapper for sending graphql queries

View File

@@ -20,15 +20,13 @@ export const createAffineCloudBlobStorage = (
? key
: `/api/workspaces/${workspaceId}/blobs/${key}`;
return fetchWithTraceReport(runtimeConfig.serverUrlPrefix + suffix).then(
async res => {
if (!res.ok) {
// status not in the range 200-299
return undefined;
}
return await res.blob();
return fetchWithTraceReport(suffix).then(async res => {
if (!res.ok) {
// status not in the range 200-299
return undefined;
}
);
return await res.blob();
});
},
set: async (key, value) => {
const {

View File

@@ -7,9 +7,16 @@ export function getIoManager(): Manager {
if (ioManager) {
return ioManager;
}
ioManager = new Manager(runtimeConfig.serverUrlPrefix + '/', {
autoConnect: false,
transports: ['websocket'],
});
const { protocol, hostname, port } = window.location;
ioManager = new Manager(
`${protocol === 'https:' ? 'wss' : 'ws'}://${hostname}${
port ? `:${port}` : ''
}/`,
{
autoConnect: false,
transports: ['websocket'],
secure: location.protocol === 'https:',
}
);
return ioManager;
}