Update default cors headers

This commit is contained in:
Andrey Antukh 2026-02-10 19:08:21 +01:00
parent cfcebf59d5
commit 12bc3ac9ed
6 changed files with 20 additions and 5 deletions

View File

@ -213,14 +213,14 @@
(assoc "access-control-allow-origin" origin)
(assoc "access-control-allow-methods" "GET,POST,DELETE,OPTIONS,PUT,HEAD,PATCH")
(assoc "access-control-allow-credentials" "true")
(assoc "access-control-expose-headers" "x-requested-with, content-type, cookie")
(assoc "access-control-allow-headers" "x-frontend-version, content-type, accept, x-requested-width")))
(assoc "access-control-expose-headers" "content-type, set-cookie")
(assoc "access-control-allow-headers" "x-frontend-version, x-client, x-requested-width, content-type, accept, cookie")))
(defn wrap-cors
[handler]
(fn [request]
(let [response (if (= (yreq/method request) :options)
{::yres/status 200}
{::yres/status 204}
(handler request))
origin (yreq/get-header request "origin")]
(update response ::yres/headers with-cors-headers origin))))

View File

@ -11,7 +11,7 @@ import comments from './plugins/create-comments';
import { Agent } from './utils/agent';
describe('Plugins', () => {
it('create board - text - rectable', async () => {
it.only('create board - text - rectable', async () => {
const agent = await Agent();
const result = await agent.runCode(testingPlugin.toString(), {
screenshot: 'create-board-text-rect',

View File

@ -60,6 +60,9 @@ export async function Agent() {
const page = await browser.newPage();
await page.setViewport({ width: 1920, height: 1080 });
await page.setExtraHTTPHeaders({
'X-Client': 'plugins/e2e:puppeter',
});
console.log('Setting authentication cookie...');
page.setCookie({

View File

@ -10,6 +10,7 @@ export async function PenpotApi() {
const resultLoginRequest = await fetch(
`${apiUrl}/api/rpc/command/login-with-password`,
{
credentials: 'include',
method: 'POST',
headers: {
'Content-Type': 'application/transit+json',
@ -21,7 +22,15 @@ export async function PenpotApi() {
},
);
console.log("AAAAAAAAAAAA", 1, apiUrl)
// console.log("AAAAAAAAAAAA", 2, resultLoginRequest);
console.dir(resultLoginRequest.headers, {depth:20});
console.log('Document Cookies:', window.document.cookie);
const loginData = await resultLoginRequest.json();
const authToken = resultLoginRequest.headers
.get('set-cookie')
?.split(';')

View File

@ -14,6 +14,6 @@ export default defineConfig({
reportsDirectory: '../coverage/e2e',
provider: 'v8',
},
setupFiles: ['dotenv/config'],
setupFiles: ['dotenv/config', 'vitest.setup.ts']
},
});

View File

@ -0,0 +1,3 @@
// import { vi } from 'vitest';
window.location.href = 'https://localhost:3449';