Skip to content

Instantly share code, notes, and snippets.

@tzkmx
Last active March 9, 2021 00:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tzkmx/56d6f1c8c0a55abf2083858e55438d11 to your computer and use it in GitHub Desktop.
Save tzkmx/56d6f1c8c0a55abf2083858e55438d11 to your computer and use it in GitHub Desktop.
Simple static response for Azure Function LetsEncrypt Domain Verification
{
"bindings": [
{
"authLevel": "Anonymous",
"type": "httpTrigger",
"direction": "in",
"name": "req",
"route": ".well-known/acme-challenge/{hash}",
"methods": [
"get"
]
},
{
"type": "http",
"direction": "out",
"name": "$return"
}
]
}
const {join} = require('path')
const {existsSync, readFileSync} = require('fs')
module.exports = async function (context, req) {
const {hash} = req.params
const lookupFor = join(__dirname, '../.well-known/acme-challenge/', hash)
if (!existsSync(lookupFor)) {
return {
status: 404,
body: 'not found'
}
}
const content = readFileSync(lookupFor)
return {
body: content
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment