发现使用本地文件模式输出的 cookie 相比 remote 模式貌似少了一部分,包括在项目描述里面的 docker 方式使用 部分的第一张截图也是这样。
看了下这个 jsdom 的 Cookie jars
Like web browsers, jsdom has the concept of a cookie jar, storing HTTP cookies. Cookies that have a URL on the same domain as the document, and are not marked HTTP-only, are accessible via the document.cookie API. Additionally, all cookies in the cookie jar will impact the fetching of subresources.
说是获取不到 http-only 标记的 cookie,但是远程模式的那个 jsdomFromUrl
Any cookies set via HTTP Set-Cookie response headers are stored in the jsdom's cookie jar. Similarly, any cookies already in a supplied cookie jar are sent as HTTP Cookie request headers.
第一次请求 412 返回的 Set-Cookie 请求头也会存进 cookie jars 里面,所以可以对应上。
目前我是将 https://github.com/pysunday/rs-reverse/blob/main/utils/getCode.js#L42 这里加上了一行打印返回包的 header 获取到的:
logger.warn(`header: ${res.headers['set-cookie']}`)
然后进行 makecode 就可以获取到这个 http-only 的 cookie:
it's work🤣,但是想问下是否有更好的办法
发现使用本地文件模式输出的 cookie 相比 remote 模式貌似少了一部分,包括在项目描述里面的 docker 方式使用 部分的第一张截图也是这样。
看了下这个 jsdom 的 Cookie jars
说是获取不到 http-only 标记的 cookie,但是远程模式的那个 jsdomFromUrl
第一次请求 412 返回的 Set-Cookie 请求头也会存进 cookie jars 里面,所以可以对应上。
目前我是将 https://github.com/pysunday/rs-reverse/blob/main/utils/getCode.js#L42 这里加上了一行打印返回包的 header 获取到的:
然后进行 makecode 就可以获取到这个 http-only 的 cookie:
it's work🤣,但是想问下是否有更好的办法