Apply the auto-fixable lint rules and the formatter, and drop the Vite build artifacts.
This commit is contained in:
+20
-14
@@ -72,7 +72,10 @@ function serverMatrixSdkCryptoWasm(wasmFilePath) {
|
||||
configureServer(server) {
|
||||
server.middlewares.use((req, res, next) => {
|
||||
if (req.url === wasmFilePath) {
|
||||
const resolvedPath = path.join(path.resolve(), "/node_modules/@matrix-org/matrix-sdk-crypto-wasm/pkg/matrix_sdk_crypto_wasm_bg.wasm");
|
||||
const resolvedPath = path.join(
|
||||
path.resolve(),
|
||||
'/node_modules/@matrix-org/matrix-sdk-crypto-wasm/pkg/matrix_sdk_crypto_wasm_bg.wasm',
|
||||
);
|
||||
|
||||
if (fs.existsSync(resolvedPath)) {
|
||||
res.setHeader('Content-Type', 'application/wasm');
|
||||
@@ -190,10 +193,10 @@ function corsProxyMiddleware() {
|
||||
if (corsProxyMatch) {
|
||||
const [, hostname, pathname] = corsProxyMatch;
|
||||
const targetUrl = `https://${hostname}${pathname}`;
|
||||
|
||||
|
||||
console.log(`[CORS Proxy] ${req.method} ${req.url}`);
|
||||
console.log(`[CORS Proxy] Target: ${targetUrl}`);
|
||||
|
||||
|
||||
// Handle preflight OPTIONS request
|
||||
if (req.method === 'OPTIONS') {
|
||||
res.setHeader('Access-Control-Allow-Origin', '*');
|
||||
@@ -203,7 +206,7 @@ function corsProxyMiddleware() {
|
||||
res.end();
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
try {
|
||||
// Collect request body for POST/PUT
|
||||
let body = null;
|
||||
@@ -215,32 +218,35 @@ function corsProxyMiddleware() {
|
||||
body = Buffer.concat(chunks).toString();
|
||||
console.log(`[CORS Proxy] Request body:`, body);
|
||||
}
|
||||
|
||||
|
||||
// Forward request with method, headers, and body
|
||||
const fetchOptions = {
|
||||
method: req.method,
|
||||
headers: {
|
||||
'Content-Type': req.headers['content-type'] || 'application/json',
|
||||
'Authorization': req.headers['authorization'] || '',
|
||||
Authorization: req.headers['authorization'] || '',
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
if (body) {
|
||||
fetchOptions.body = body;
|
||||
}
|
||||
|
||||
|
||||
const response = await fetch(targetUrl, fetchOptions);
|
||||
const data = await response.text();
|
||||
|
||||
|
||||
console.log(`[CORS Proxy] Response status: ${response.status}`);
|
||||
console.log(`[CORS Proxy] Response data:`, data.substring(0, 500));
|
||||
|
||||
|
||||
// Set CORS headers
|
||||
res.setHeader('Access-Control-Allow-Origin', '*');
|
||||
res.setHeader('Access-Control-Allow-Methods', 'GET, POST, PUT, DELETE, OPTIONS');
|
||||
res.setHeader('Access-Control-Allow-Headers', 'Content-Type, Authorization');
|
||||
res.setHeader('Content-Type', response.headers.get('content-type') || 'application/json');
|
||||
|
||||
res.setHeader(
|
||||
'Content-Type',
|
||||
response.headers.get('content-type') || 'application/json',
|
||||
);
|
||||
|
||||
res.writeHead(response.status);
|
||||
res.end(data);
|
||||
} catch (error) {
|
||||
@@ -330,8 +336,8 @@ export default defineConfig(() => ({
|
||||
},
|
||||
devOptions: {
|
||||
enabled: false,
|
||||
type: 'module'
|
||||
}
|
||||
type: 'module',
|
||||
},
|
||||
}),
|
||||
],
|
||||
optimizeDeps: {
|
||||
|
||||
Reference in New Issue
Block a user