Howdy folks!
Iโve stumbled upon a roadblock when trying to build a Netlify Build plugin.
As a part of that plugin, I need to send HTTP requests. The problem is that I canโt get HTTP requests to run. Iโve tried different HTTP libraries to no avail.
Hereโs my index.js file:
'use strict';
const https = require('https');
module.exports = {
name: 'hello-world-plugin',
onEnd: async () => {
console.log('Starting the execution');
const request = https.get({ hostname: 'tryhexadecimal.com' }, (response) => {
console.log('Sending HTTP request');
const certificate = response.connection.getPeerCertificate();
const dateInfo = {
valid_from: certificate.valid_from,
valid_to: certificate.valid_to,
issuer: certificate.issuer.CN,
fingerprint: certificate.fingerprint,
serialNumber: certificate.serialNumber
};
console.log(response.code);
console.log(JSON.stringify(dateInfo));
});
request.on('error', (e) => {
console.log(JSON.stringify(e.message));
})
request.end();
console.log('Finita!');
}
}
Hereโs the build output from the netlify build
command. As you can see below, Sending HTTP request
message doesnโt appear in the console. Iโve tried different URLs to see if that request appears in server logs, but there was nothing. Any ideas?
The script itself works, though.
โฏ Starting Netlify Build v0.1.117
https://github.com/netlify/build
โ
โฏ Flags
dry: false
โ
โฏ Current directory
~/hexadecimal-static
โ
โฏ Config file
~/hexadecimal-static/netlify.toml
โ
โฏ Context
production
โ
โฏ Installing local plugins dependencies
- ./plugins/netlify-plugin-hello-world
โ
โฏ Loading plugins
- ./plugins/netlify-plugin-hello-world
โ
โฏ Running Netlify Build Lifecycle
Found 2 commands. Let's do this!
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ 1. Running build.lifecycle.onBuild command from netlify.toml config file โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
Running command "bundle exec nanoc compile --env=prod && bundle exec nanoc check mixed_content stale ilinks && bundle exec ruby post_process.rb"
Loading siteโฆ done
~/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/nanoc-core-4.11.15/lib/nanoc/core/compiler_loader.rb:35: warning: Using the last argument as keyword parameters is deprecated; maybe ** should be added to the call
~/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/nanoc-core-4.11.15/lib/nanoc/core/compiler.rb:8: warning: The called method `initialize' is defined here
Compiling siteโฆ
Site compiled in 0.13s.
Loading siteโฆ done
~/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/nanoc-core-4.11.15/lib/nanoc/core/compiler_loader.rb:35: warning: Using the last argument as keyword parameters is deprecated; maybe ** should be added to the call
~/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/nanoc-core-4.11.15/lib/nanoc/core/compiler.rb:8: warning: The called method `initialize' is defined here
Running check mixed_contentโฆ ok
Running check staleโฆ ok
Running check internal_linksโฆ ok
โ
โ build.lifecycle.onBuild completed in 3637ms
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ 2. Running onEnd command from ./plugins/netlify-plugin-hello-world โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
Starting the execution
Finita!
โ
โ ./plugins/netlify-plugin-hello-world onEnd completed in 31ms
โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Netlify Build Complete โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โ Netlify Build completed in 6105ms
โ
(๏พโใฎโ)๏พ*:๏ฝฅ๏พโง Have a nice day!