Last active
March 9, 2021 00:27
-
-
Save tzkmx/56d6f1c8c0a55abf2083858e55438d11 to your computer and use it in GitHub Desktop.
Simple static response for Azure Function LetsEncrypt Domain Verification
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"bindings": [ | |
{ | |
"authLevel": "Anonymous", | |
"type": "httpTrigger", | |
"direction": "in", | |
"name": "req", | |
"route": ".well-known/acme-challenge/{hash}", | |
"methods": [ | |
"get" | |
] | |
}, | |
{ | |
"type": "http", | |
"direction": "out", | |
"name": "$return" | |
} | |
] | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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