# Why is a proxy redirect working with Vite but not Koa?

**URL:** <https://community.auth0.com/t/why-is-a-proxy-redirect-working-with-vite-but-not-koa/70109>\
**Category:** Get Help\
**Created:** [September 22, 2021, 5:59pm UTC](https://community.auth0.com/t/why-is-a-proxy-redirect-working-with-vite-but-not-koa/70109 "2021-09-22T17:59:21Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![jgleason](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/jgleason/32/25904_2.png) [@jgleason](https://community.auth0.com/u/jgleason)\
**Post date:** [September 22, 2021, 5:59pm UTC](https://community.auth0.com/t/why-is-a-proxy-redirect-working-with-vite-but-not-koa/70109/1 "2021-09-22T17:59:21Z")

</div>

I have the following in my vite.config…

```auto
export default {
  plugins: [vue(), loadVersion()],
  build: {
    chunkSizeWarningLimit: 1000,
  },

  server: {
    host: "0.0.0.0",
    port: 8080,
    proxy: {
      "/login": {
        target: coreUrl,
        changeOrigin: true,
      },
      "/logout": {
        target: coreUrl,
        changeOrigin: true,
      },
      "/userinfo": {
        target: coreUrl,
        changeOrigin: true,
      },
      "/g": {
        target: coreUrl,
        changeOrigin: true,
      },
      "/api": {
        target: coreUrl,
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/api/, ""),
      },
    },
  },
};

```

And I have the following endpoint on the other side…

```auto
import { auth } from "express-openid-connect";
app.use(auth(jwtConfig));
app.get("/login", (req, res) => res.oidc.login({ returnTo: redirectUrl }));

```

When I run it this way and try to access `http://<frontend IP>:<frontend port>/login`, everything redirects correctly. However, we also need to be able to run using Koa so I try the following…

```auto
router.get('/login', proxy({
  url: `${coreUrl}/login`
}));

```

When the redirect happens I get an Auth0 error page stating…

### Oops!, something went wrong

There could be a misconfiguration in the system or a service outage. We track these errors automatically, but if the problem persists feel free to contact us.  
Please try again.

Why is it working with the vite proxy but not the koa one? Could this be related to it running on port 80?

---

<div class="post-metadata">

**Author:** ![jgleason](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/jgleason/32/25904_2.png) [@jgleason](https://community.auth0.com/u/jgleason)\
**Post date:** [September 22, 2021, 8:51pm UTC](https://community.auth0.com/t/why-is-a-proxy-redirect-working-with-vite-but-not-koa/70109/2 "2021-09-22T20:51:44Z")

</div>

I got it working by switching to koa-proxies…

```auto
const proxy = require("koa-proxies");
app.use(proxy("/login", {
  target: `${coreUrl}`,
  changeOrigin: true,
}));

```

---

<div class="post-metadata">

**Author:** ![konrad.sopala](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/konrad.sopala/32/13516_2.png) [@konrad.sopala](https://community.auth0.com/u/konrad.sopala)\
**Post date:** [September 23, 2021, 11:28am UTC](https://community.auth0.com/t/why-is-a-proxy-redirect-working-with-vite-but-not-koa/70109/3 "2021-09-23T11:28:07Z")

</div>

Wooah! Thanks for sharing that with the rest of community!

---

<div class="post-metadata">

**Author:** ![konrad.sopala](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/konrad.sopala/32/13516_2.png) [@konrad.sopala](https://community.auth0.com/u/konrad.sopala)\
**Post date:** [September 30, 2021, 9:41am UTC](https://community.auth0.com/t/why-is-a-proxy-redirect-working-with-vite-but-not-koa/70109/4 "2021-09-30T09:41:31Z")

</div>


