mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-13 21:05:19 +00:00
fix: client indexing & outdated scheme (#14160)
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit
* **New Features**
* Optimized storage handling with platform-specific
implementations—SQLite for Electron and IndexedDB for other environments
for improved performance.
* **Bug Fixes**
* Enhanced recording file access and retrieval functionality for better
reliability.
* Strengthened local file protocol handling and security restrictions.
<sub>✏️ Tip: You can customize this high-level summary in your review
settings.</sub>
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
@@ -20,16 +20,6 @@ protocol.registerSchemesAsPrivileged([
|
||||
stream: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
scheme: 'file',
|
||||
privileges: {
|
||||
secure: false,
|
||||
corsEnabled: true,
|
||||
supportFetchAPI: true,
|
||||
standard: true,
|
||||
stream: true,
|
||||
},
|
||||
},
|
||||
]);
|
||||
|
||||
const webStaticDir = join(resourcesPath, 'web-static');
|
||||
@@ -152,10 +142,6 @@ function ensureFrameAncestors(
|
||||
}
|
||||
|
||||
export function registerProtocol() {
|
||||
protocol.handle('file', request => {
|
||||
return handleFileRequest(request);
|
||||
});
|
||||
|
||||
protocol.handle('assets', request => {
|
||||
return handleFileRequest(request);
|
||||
});
|
||||
@@ -202,15 +188,12 @@ export function registerProtocol() {
|
||||
|
||||
const { protocol } = new URL(url);
|
||||
|
||||
// Only adjust CORS for assets/file responses; leave remote http(s) headers intact
|
||||
if (protocol === 'assets:' || protocol === 'file:') {
|
||||
// Only adjust CORS for assets responses; leave remote http(s) headers intact
|
||||
if (protocol === 'assets:') {
|
||||
delete responseHeaders['access-control-allow-origin'];
|
||||
delete responseHeaders['access-control-allow-headers'];
|
||||
delete responseHeaders['Access-Control-Allow-Origin'];
|
||||
delete responseHeaders['Access-Control-Allow-Headers'];
|
||||
}
|
||||
|
||||
if (protocol === 'assets:' || protocol === 'file:') {
|
||||
setHeader(responseHeaders, 'X-Frame-Options', 'SAMEORIGIN');
|
||||
ensureFrameAncestors(responseHeaders, "'self'");
|
||||
}
|
||||
|
||||
@@ -42,10 +42,6 @@ app.on('web-contents-created', (_, contents) => {
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
if (parsed.protocol === 'file:' && parsed.hostname === mainHost) {
|
||||
// legacy allowance for older file:// loads
|
||||
return true;
|
||||
}
|
||||
} catch {}
|
||||
return false;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user