WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This plugin intercepts /incoming and returns /try/incoming instead at the original URL.
The part I can't make work is when it loads /try/incoming it makes an API call. Depending on the result it should fail the original request with a 500 code, or return /try/incomingIfExists if that exists otherwise /try/incomingFallback.
configureServer(server) {
server.middlewares.use(async (req, res, next) => {
if (req.url === "/incoming") {
req.url === "/try/incoming"
await next()
}
if (req.url === "/try/incoming") {
const apistatus = (await fetch(api)).status
if (apistatus === 400) {
res.statusCode = 500
} else {
req.url = "/try/incomingIfExists"
await next()
}
}
if (req.url === "/try/incomingIfExists") {
// How to do it only if /try/incomingIfExists doesn't exist?
req.url = "/try/incomingFallback"
}
})
}
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
This plugin intercepts
/incomingand returns/try/incominginstead at the original URL.The part I can't make work is when it loads
/try/incomingit makes an API call. Depending on the result it should fail the original request with a 500 code, or return/try/incomingIfExistsif that exists otherwise/try/incomingFallback.Beta Was this translation helpful? Give feedback.
All reactions