Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set headers or Cookies for request in CLI #596

Open
superdav42 opened this issue Jun 5, 2024 · 2 comments
Open

Set headers or Cookies for request in CLI #596

superdav42 opened this issue Jun 5, 2024 · 2 comments

Comments

@superdav42
Copy link

Hi,
I'm trying to generate critical css for a url that needs a specific cookie to be accessible. I'm working with the CLI since my project is not based on node. It seems like it might be possible to send the right headers with the cli but I'm not sure exact options I should use. I've tried:

DEBUG="critical:*" critical 'https://www.example.com/' --request-headers 'cookie: key=value;'

But it fails with:

Error: Expected value which is `plain object`, received value of type `string`.

Full debug shows:

Fetching resource: https://www.example.com/ {
  headers: 'cookie: key=value;',
  method: 'head',
  https: { rejectUnauthorized: true }
}

Obviously it's expecting headers to be an object and not a string but it seems impossible to make it an option just with cli options. Is there a trick to make it work?

bezoerb added a commit that referenced this issue Aug 16, 2024
@bezoerb
Copy link
Collaborator

bezoerb commented Aug 16, 2024

Hey @superdav42,

thanks for reporting the issue. I build something so you could pass a JSON string as CLI argument:

node cli.js  'https://www.example.com/' --request-headers='{"cookie":"key=value"}'

@bezoerb
Copy link
Collaborator

bezoerb commented Aug 17, 2024

can you try v7.2.0 please?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants