-
I'm trying to use an existing express application inside SvelteKit response handler. I detail here a minimal example. cd /tmp
npm init svelte@next test
# Chose Skeleton Project
cd test && npm install
npm install -D express Then we fake an existing express application in import express from 'express'
export let app = express()
app.get("/status", (req, res) => res.send("Status OK!")) How to set things up in import { app } from '$lib/server.js'
export async function handle({ event, resolve }) {
return app(event.request, resolve, async () => {
return await resolve(event)
})
} I thought this should be a way to let the express application answer, and if the application can't then we pass as next method the usual SvelteKit resolve. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
If you're using |
Beta Was this translation helpful? Give feedback.
handle
needs to return aResponse
, but it looks like you have it returning an Express app?If you're using
adapter-node
you could use a custom server and add any middleware there: https://kit.svelte.dev/faq#integrations-how-do-i-use-middleware