SolidJSS
SolidJSโ€ข13mo agoโ€ข
3 replies
chasingtheflow

How to set up a vite dev proxy with Start and Vinxi?

I am trying to figure out how to migrate a dev proxy for api requests in solidstart. I have a working config just for a normal solidjs app which looks like the following in vite.config.ts

import { defineConfig, loadEnv } from "vite";
import solidPlugin from "vite-plugin-solid";

export default defineConfig(({ mode }) => {
  const env = loadEnv(mode, process.cwd(), "");

  return {
    plugins: [solidPlugin()],
    server: {
      port: 3000,
      proxy: {
        "/api": {
          target: env.SN_URL,
          changeOrigin: true,
          configure: (proxy, options) => {
            proxy.on("proxyReq", (proxyReq) => {
              const username = env.SN_UN;
              const password = env.SN_PW;
              const authString = Buffer.from(
                `${username}:${password}`,
              ).toString("base64");
              proxyReq.setHeader("Authorization", `Basic ${authString}`);
            });
          },
        },
      },
    },
    build: {
      target: "esnext",
    },
  };
});


and I'm trying to figure out how to modify the
app.config.ts
file provided by Start to do something similar. Right now my starter file looks like this:

import { defineConfig } from "@solidjs/start/config";

export default defineConfig({
  vite: {
    ssr: { external: ["drizzle-orm"] },
  },
});
Was this page helpful?