(url)
| 22 | }; |
| 23 | |
| 24 | const cookieHandler = async (url) => { |
| 25 | let headerCookies = null; |
| 26 | let clientCookies = null; |
| 27 | |
| 28 | try { |
| 29 | const response = await httpGet(url); |
| 30 | headerCookies = response.headers['set-cookie']; |
| 31 | } catch (error) { |
| 32 | if (error.response) { |
| 33 | return { error: `Request failed with status ${error.response.status}: ${error.message}` }; |
| 34 | } |
| 35 | return { error: `No response received: ${error.message}` }; |
| 36 | } |
| 37 | |
| 38 | try { |
| 39 | clientCookies = await getPuppeteerCookies(url); |
| 40 | } catch (_) { |
| 41 | clientCookies = null; |
| 42 | } |
| 43 | |
| 44 | return { |
| 45 | headerCookies: headerCookies || [], |
| 46 | clientCookies: clientCookies || [], |
| 47 | }; |
| 48 | }; |
| 49 | |
| 50 | export const handler = middleware(cookieHandler); |
| 51 | export default handler; |
nothing calls this directly
no test coverage detected