11 lines
509 B
TypeScript
11 lines
509 B
TypeScript
import type { Request } from '@playwright/test';
|
|
|
|
export function replayWithoutSession(request: Request, origin: string) {
|
|
const headers = new Headers({ origin });
|
|
const contentType = request.headers()['content-type'];
|
|
if (contentType) headers.set('content-type', contentType);
|
|
const options: RequestInit = { method: request.method(), headers, redirect: 'error' };
|
|
if (request.method() !== 'GET' && request.method() !== 'HEAD') options.body = request.postData();
|
|
return fetch(request.url(), options);
|
|
}
|