Next.js Discord

Discord Forum

proxying websocket endpoint in nextjs

Unanswered
Kerry Blue Terrier posted this in #help-forum
Open in Discord
Kerry Blue TerrierOP
i am proxying my backend api in the next.config.js
    async rewrites() {
        const development = process.env.NEXT_PUBLIC_ENV === "development";
        const BASEURL = development
            ? process.env.NEXT_PUBLIC_DEV_URL
            : process.env.NEXT_PUBLIC_PROD_URL;

        return [
            {
                source: "/api/:path*/",
                destination: `${BASEURL}/api/:path*/`, // Proxy to the appropriate URL based on the environment
            },
        ];
    },

the api route for the ws is /api/ws
im unable to connect to it, and i dont see any logs on the backend
do i need to do something to proxy ws endpoints?

0 Replies