bnason
bnason
Explore posts from servers
CDCloudflare Developers
Created by bnason on 6/25/2024 in #workers-help
Error 1101 on code surrounded by try/catch
As you can see it stops on console.log(3) but it should show console.log(6) if there was an exception thrown!
4 replies
CDCloudflare Developers
Created by bnason on 6/25/2024 in #workers-help
Error 1101 on code surrounded by try/catch
This is what tailing the logs shows:
{
"outcome": "exception",
"scriptName": "pages-worker--3037681-production",
"diagnosticsChannelEvents": [],
"exceptions": [
{
"name": "Error",
"message": "The script will never generate a response.",
"timestamp": 1719317831505
}
],
"logs": [
{
"message": [
1
],
"level": "log",
"timestamp": 1719317831505
},
{
"message": [
2
],
"level": "log",
"timestamp": 1719317831505
},
{
"message": [
3
],
"level": "log",
"timestamp": 1719317831505
}
],
"eventTimestamp": 1719317831505,
"event": {
"response": {
"status": 500
}
},
"id": 1
}
{
"outcome": "exception",
"scriptName": "pages-worker--3037681-production",
"diagnosticsChannelEvents": [],
"exceptions": [
{
"name": "Error",
"message": "The script will never generate a response.",
"timestamp": 1719317831505
}
],
"logs": [
{
"message": [
1
],
"level": "log",
"timestamp": 1719317831505
},
{
"message": [
2
],
"level": "log",
"timestamp": 1719317831505
},
{
"message": [
3
],
"level": "log",
"timestamp": 1719317831505
}
],
"eventTimestamp": 1719317831505,
"event": {
"response": {
"status": 500
}
},
"id": 1
}
4 replies
CDCloudflare Developers
Created by bnason on 6/25/2024 in #workers-help
Error 1101 on code surrounded by try/catch
import { SAML } from 'saml-login'

export default defineEventHandler(async (event) => {
try {
console.log(1)
const saml = new SAML()

console.log(2)
const options: Parameters<typeof saml.generateAuthenticationUrl>[0] = {
providerSingleSignOnUrl: 'xxx',
applicationEntityId: 'xxx',
applicationCallbackAssertionConsumerServiceUrl: `http${process.env.NODE_ENV === 'production' ? 's' : ''}://${
process.env.SITE_DOMAIN
}/auth/saml/sp/acs`,
allowCreate: false,
}
console.log(3)
const redirectUrl = await saml.generateAuthenticationUrl(options)

console.log(4)
sendRedirect(event, redirectUrl)

console.log(5)
return ''
} catch (e) {
console.log(6)
if (e instanceof Error) {
console.log(e.message)
}

return 'error'
}
})
import { SAML } from 'saml-login'

export default defineEventHandler(async (event) => {
try {
console.log(1)
const saml = new SAML()

console.log(2)
const options: Parameters<typeof saml.generateAuthenticationUrl>[0] = {
providerSingleSignOnUrl: 'xxx',
applicationEntityId: 'xxx',
applicationCallbackAssertionConsumerServiceUrl: `http${process.env.NODE_ENV === 'production' ? 's' : ''}://${
process.env.SITE_DOMAIN
}/auth/saml/sp/acs`,
allowCreate: false,
}
console.log(3)
const redirectUrl = await saml.generateAuthenticationUrl(options)

console.log(4)
sendRedirect(event, redirectUrl)

console.log(5)
return ''
} catch (e) {
console.log(6)
if (e instanceof Error) {
console.log(e.message)
}

return 'error'
}
})
4 replies
CDCloudflare Developers
Created by bnason on 6/24/2024 in #workers-help
import is undefined
That did not seem to help unfortunately
4 replies
CDCloudflare Developers
Created by bnason on 6/24/2024 in #workers-help
import is undefined
let me try that thanks
4 replies
CDCloudflare Developers
Created by bnason on 6/24/2024 in #wrangler
So wrangler just made me go through the
Ok I did a wrangler login and that completed the flow. The issue I looked at said the deploy process might be hitting an extra CloudFlare challenge that is returning HTML instead of whatever the oauth process needed.
3 replies
CDCloudflare Developers
Created by bnason on 6/22/2024 in #workers-help
SAML
Is there a way to know what exactly is triggering that error?
2 replies
NNuxt
Created by bnason on 6/21/2024 in #❓・help
Express compatible request object
Now to get that body parser only on that route
27 replies
NNuxt
Created by bnason on 6/21/2024 in #❓・help
Express compatible request object
aha! export default fromNodeMiddleware(bodyParser.urlencoded({ extended: false }))
27 replies
NNuxt
Created by bnason on 6/21/2024 in #❓・help
Express compatible request object
ok I don't know why it's looking at the body... the damn thing is urlencoded!
27 replies
NNuxt
Created by bnason on 6/21/2024 in #❓・help
Express compatible request object
Weird, even using a normal event handler, the body is { '{}': '' }
export default defineEventHandler(async (event) => {
const body = await readBody(event)
console.log(JSON.stringify(body))
})
export default defineEventHandler(async (event) => {
const body = await readBody(event)
console.log(JSON.stringify(body))
})
27 replies
NNuxt
Created by bnason on 6/21/2024 in #❓・help
Express compatible request object
export default fromNodeMiddleware(bodyParser.text())
27 replies
NNuxt
Created by bnason on 6/21/2024 in #❓・help
Express compatible request object
I even installed bodyParser as a server middleware but that just gives me an empty object {} instead of undefined
27 replies
NNuxt
Created by bnason on 6/21/2024 in #❓・help
Express compatible request object
nope =\
27 replies
NNuxt
Created by bnason on 6/21/2024 in #❓・help
Express compatible request object
hmm i bet its the async
27 replies
NNuxt
Created by bnason on 6/21/2024 in #❓・help
Express compatible request object
import jwt from 'jsonwebtoken'

import { identityProvider, serviceProvider } from '~/server/utils/saml'

export default fromNodeMiddleware(async (request, response) => {
try {
const { extract } = await serviceProvider.parseLoginResponse(identityProvider, 'post', request)
const { session } = extract.attributes

const cookie = jwt.sign(session, process.env.SESSION_SECRET || 'foobar', { expiresIn: '1h' })

// setCookie(event, 'SESSION', cookie)
} catch (e) {
console.error('[FATAL] when parsing login response sent from IdP', e)
}
})
import jwt from 'jsonwebtoken'

import { identityProvider, serviceProvider } from '~/server/utils/saml'

export default fromNodeMiddleware(async (request, response) => {
try {
const { extract } = await serviceProvider.parseLoginResponse(identityProvider, 'post', request)
const { session } = extract.attributes

const cookie = jwt.sign(session, process.env.SESSION_SECRET || 'foobar', { expiresIn: '1h' })

// setCookie(event, 'SESSION', cookie)
} catch (e) {
console.error('[FATAL] when parsing login response sent from IdP', e)
}
})
27 replies