Run curl-style HTTP requests from inside a browser tab, using that tab's cookies and session.
Synopsis
curlwright [options] <url>
Description
curlwright issues the request via a page-context fetch() in a browser tab, so it carries that tab's cookies, origin, TLS session and service-worker routing. Use it against an app's own backend when a plain sandboxed curl would get a 401/403/421 because it lacks the tab's session. Redirects are always followed since a page fetch cannot surface intermediate 3xx responses.
Options
-X, --request <method> HTTP method (default GET, or POST with a body).
-H, --header <line> Add a header; repeatable. 'Name;' sends it empty, 'Name:' suppresses a default header.
-d, --data <data> Request body; @file reads from the VFS.
--data-raw <data> Body, with no @file expansion.
--data-binary <data> Body; @file keeps newlines and raw bytes.
--data-urlencode <d> URL-encode content, =content, name=content, or name@file.
--json <data> Body plus Content-Type/Accept: application/json.
-F, --form <name=content> multipart/form-data; @file uploads, <file inlines.
--form-string <n=c> multipart field, taken literally.
-G, --get Send --data as a query string.
-u, --user <user:pass> Basic auth.
-e, --referer <url> Set the request referrer.
-r, --range <range> Add a Range header.
--no-credentials Do not send cookies (sent by default).
--tab <targetId> Tab to run in.
--frame <frameId> Run in a child frame of that tab.
-o, --output <file> Write the body to a VFS file ("-" = stdout).
-O, --remote-name Write to the URL's last path segment.
-i, --include Print response headers before the body.
-I, --head Send HEAD and print only the headers.
-D, --dump-header <file> Write response headers to a file.
-w, --write-out <format> Print a format string after the transfer.
-s, --silent Suppress error messages.
-S, --show-error Show errors even with -s.
-v, --verbose Trace the request and response to stderr.
-f, --fail No body on HTTP >= 400; exit 22.
-m, --max-time <seconds> Abort the request after this long; exit 28.
Examples
$ curlwright https://app.example.com/api/me
Call an app's own API using the open tab's session cookies.
$ P
O
Notes
A body on GET or HEAD is rejected (exit 2); use -G to put data in the query string. Exit codes: 0 ok, 2 bad usage, 7 fetch failed, 22 --fail on HTTP>=400, 23 write error, 26 cannot read input file, 28 --max-time expired. Different from plain curl, which runs outside any browser tab and has no access to page cookies/session.
See Also
curl, playwright-cli, websocat