# Configure multiple API's for the same client

**URL:** <https://community.auth0.com/t/configure-multiple-apis-for-the-same-client/60881>\
**Category:** Get Help\
**Tags:** express\
**Created:** [April 10, 2021, 11:49pm UTC](https://community.auth0.com/t/configure-multiple-apis-for-the-same-client/60881 "2021-04-10T23:49:51Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![muhammad.salman](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/muhammad.salman/32/23141_2.png) [@muhammad.salman](https://community.auth0.com/u/muhammad.salman)\
**Post date:** [April 10, 2021, 11:49pm UTC](https://community.auth0.com/t/configure-multiple-apis-for-the-same-client/60881/1 "2021-04-10T23:49:51Z")

</div>

Hi

I am using **[express-openid-connect](https://github.com/auth0/express-openid-connect)** and am trying to have different middleware config based on the protected API server I want to call. Trying to do that gives me an **Error: req[appSession] is already set, did you run this middleware twice?**  
The code is as below

```
const config = {
  authRequired: false,
  routes: { login: false },
  auth0Logout: true,
  baseURL: 'https://localhost/',
  clientID: '....',
  clientSecret: '....',
  issuerBaseURL: '...',
  secret: 'LONG_RANDOM_STRING',
};

app.use('/', auth(config));

app.use(
  '/proxy/api',
  auth({
    ...config,
    authorizationParams: {
      response_type: 'code',
      audience: '....',
      scope: 'openid profile email',
      prompt: 'consent',
    },
    session: { cookie: { path: '/' } },
  })
);

```

Any help would be appreciated.

Thanks!

---

<div class="post-metadata">

**Author:** ![daniel12](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/daniel12/32/12778_2.png) [@daniel12](https://community.auth0.com/u/daniel12)\
**Post date:** [January 18, 2022, 9:42pm UTC](https://community.auth0.com/t/configure-multiple-apis-for-the-same-client/60881/2 "2022-01-18T21:42:58Z")

</div>

Any response to this? I have the same question.

---

<div class="post-metadata">

**Author:** ![daniel12](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/daniel12/32/12778_2.png) [@daniel12](https://community.auth0.com/u/daniel12)\
**Post date:** [January 18, 2022, 9:51pm UTC](https://community.auth0.com/t/configure-multiple-apis-for-the-same-client/60881/3 "2022-01-18T21:51:47Z")

</div>

One workaround that I found was to pass in a different value for `session.name`. This is what determines the name of the cookie. This will avoid the conflict and resolve the error above.

---

<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:** [February 8, 2022, 2:09pm UTC](https://community.auth0.com/t/configure-multiple-apis-for-the-same-client/60881/6 "2022-02-08T14:09:18Z")

</div>

Teamwork makes the dreamwork!

---

<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:** [February 22, 2022, 2:54pm UTC](https://community.auth0.com/t/configure-multiple-apis-for-the-same-client/60881/7 "2022-02-22T14:54:18Z")

</div>


