-
-
Notifications
You must be signed in to change notification settings - Fork 11
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
HTTPError: Response code 404 (Not Found) #94
Comments
There's a few updates in the |
I don't think that's causing the problem. normalize-url 4.5.1 is the latest version that will be installed for this package, given this project's |
Thank you for investigating and clarifying. I'm a little short on time, so it may take a while before I can solve the actual problem. In the meantime, a PR to fix this would be much appreciated. |
The API that v2.4.0 of this packages uses to extract the CSS from a page is used incorrect (possibly it was updated). The SolutionIf you just want to hotfix v2.4.0, you can update const got = require('got')
const normalizeUrl = require('normalize-url')
const isUrl = require('./is-url')
module.exports = async (input, options = {}) => {
if (!isUrl(input)) {
return input
}
const url = normalizeUrl(input, {
stripWWW: false,
stripProtocol: false
})
const {body} = await got(`https://extract-css.now.sh/api/extract-css?url=${url}`, {
responseType: 'text',
resolveBodyOnly: true,
headers: {
'User-Agent': options.userAgent
}
})
return body
} Which has the following diff with this file on v2.4.0: const got = require('got')
const normalizeUrl = require('normalize-url')
const isUrl = require('./is-url')
module.exports = async (input, options = {}) => {
if (!isUrl(input)) {
return input
}
const url = normalizeUrl(input, {
stripWWW: false,
- stripProtocol: true
+ stripProtocol: false
})
- const {body} = await got(`https://extract-css.now.sh/${url}`, {
+ const {body} = await got(`https://extract-css.now.sh/api/extract-css?url=${url}`, {
responseType: 'text',
resolveBodyOnly: true,
headers: {
'User-Agent': options.userAgent
}
})
return body
} Explanationv2.4.0 makes requests as $ wallace https://projectwallace.com this will be https://extract-css.now.sh/projectwallace.com, which, as you can see by clicking the link, results in a 404. So, then I went to https://extract-css.vercel.app/ and clicked one of the examples, which rerouted me to https://extract-css.vercel.app/api/extract-css?url=https://www.google.com. From this I realized that API request should be updated: - const {body} = await got(`https://extract-css.now.sh/${url}`, {
+ const {body} = await got(`https://extract-css.now.sh/api/extract-css?url=${url}`, { Then, I tested the API without providing the protocol, e.g. https://extract-css.vercel.app/api/extract-css?url=www.google.com, which, as you can see by clicking the link, results in a 400. So, then I knew the protocol should be included so I changed: - stripProtocol: true
+ stripProtocol: false |
I have released current Thanks again for your very thorough analysis! |
Works for me 👍 Thanks for publishing an update this quickly! |
I was trying this tool out and found that I always get a 404 error when using it. Both when installed using
npm install -g
or when using it withnpx
, see logs below. Oddly enough the tool seems to work fine when I clone the repository and runsrc/cli.js
...The text was updated successfully, but these errors were encountered: