Moved CORS headers to Caddy
This commit is contained in:
@@ -6,7 +6,7 @@ var cachedResult = {}
|
|||||||
app.get("/blogposts", (rreq, rres) => {
|
app.get("/blogposts", (rreq, rres) => {
|
||||||
|
|
||||||
if (Date.now() < timeSinceLastQuery+10000) { // if it has been <10 seconds since last request
|
if (Date.now() < timeSinceLastQuery+10000) { // if it has been <10 seconds since last request
|
||||||
rres.set("Access-Control-Allow-Origin","*")
|
|
||||||
|
|
||||||
if (rreq.query.format === "html") { // if ?format=html then send HTML
|
if (rreq.query.format === "html") { // if ?format=html then send HTML
|
||||||
rres.send(cachedResult.asHtml)
|
rres.send(cachedResult.asHtml)
|
||||||
@@ -17,7 +17,7 @@ app.get("/blogposts", (rreq, rres) => {
|
|||||||
} else {
|
} else {
|
||||||
timeSinceLastQuery = Date.now()
|
timeSinceLastQuery = Date.now()
|
||||||
cachedResult = parseFiles()
|
cachedResult = parseFiles()
|
||||||
rres.set("Access-Control-Allow-Origin","*")
|
|
||||||
|
|
||||||
if (rreq.query.format === "html") { // if ?format=html then send HTML
|
if (rreq.query.format === "html") { // if ?format=html then send HTML
|
||||||
rres.send(cachedResult.asHtml)
|
rres.send(cachedResult.asHtml)
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ var currentListening = {}
|
|||||||
var currentListeningHtml = ""
|
var currentListeningHtml = ""
|
||||||
|
|
||||||
app.get("/cider", (rreq,rres) => {
|
app.get("/cider", (rreq,rres) => {
|
||||||
rres.set("Access-Control-Allow-Origin","*")
|
|
||||||
rres.send("<span>Cider endpoint is temporarily unavailable.</span>")
|
rres.send("<span>Cider endpoint is temporarily unavailable.</span>")
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -18,7 +18,7 @@ app.get("/cider", (rreq,rres) => {
|
|||||||
// if (funcRes == 1) {
|
// if (funcRes == 1) {
|
||||||
// rres.sendStatus(503) // If there was a problem getting the upstream JSON, return 503 Service Unavailable.
|
// rres.sendStatus(503) // If there was a problem getting the upstream JSON, return 503 Service Unavailable.
|
||||||
// } else {
|
// } else {
|
||||||
// rres.set("Access-Control-Allow-Origin","*") // Required (I think?) because of CORS.
|
// // Required (I think?) because of CORS.
|
||||||
// currentListening = funcRes
|
// currentListening = funcRes
|
||||||
// rres.send(funcRes)
|
// rres.send(funcRes)
|
||||||
// }
|
// }
|
||||||
|
|||||||
Reference in New Issue
Block a user