SolidJSS
SolidJS11mo ago
33 replies
De Bok

Middleware around API proxy

Hi all

I have this in my app.config.json

export default defineConfig({
    ssr: false,
    server: {
        routeRules: {
            '/api/**': {
                proxy: {
                    to: 'http://127.0.0.1:5000/**',
                }
            }
        },
    },
})


I would like to add a middleware that runs for all the requests that I receive, including the requests that get proxied.

I tried adding a normal solid js middleware using these instructions: https://docs.solidjs.com/solid-start/advanced/middleware
However this middleware doesn't execute on proxied requests.

I also tried adding a nitro middleware, but that doesn't execute at all.
https://nitro.build/guide/routing#middleware

Is there another way in which I can add a middleware that wraps everything?
Fully featured, fully customisable static site generation for SolidStart
Nitro supports filesystem routing to automatically map files to h3 routes.
Server Routes - Nitro
Was this page helpful?