# Auth0 Integration With Heroku

**URL:** <https://community.auth0.com/t/auth0-integration-with-heroku/56115>\
**Category:** Get Help\
**Created:** [January 13, 2021, 11:35am UTC](https://community.auth0.com/t/auth0-integration-with-heroku/56115 "2021-01-13T11:35:39Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![pleasehelp](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/pleasehelp/32/26873_2.png) [@pleasehelp](https://community.auth0.com/u/pleasehelp)\
**Post date:** [January 13, 2021, 11:35am UTC](https://community.auth0.com/t/auth0-integration-with-heroku/56115/1 "2021-01-13T11:35:39Z")

</div>

Hi. I am following this guide [Auth0 React SDK Quickstarts: Login](https://auth0.com/docs/quickstart/spa/react?_ga=2.31312383.1500813854.1610533221-372550992.1607515963) and my application works as expected on local host. After deploying to Heroku and updating my redirectUri however, I am receiving an undefined server IP could not be found error. Are there any other steps am I missing that are required for Heroku deployment? I found this thread [React SPA deployed on Heroku with Auth0 not working](https://community.auth0.com/t/react-spa-deployed-on-heroku-with-auth0-not-working/34010) which seems to contain my same issue, but I don’t understand the solution. I’m very new to both Heroku and Auth0 so I would really appreciate some help. Thanks.

---

<div class="post-metadata">

**Author:** ![stephanie.chamblee](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/stephanie.chamblee/32/26087_2.png) [@stephanie.chamblee](https://community.auth0.com/u/stephanie.chamblee)\
**Post date:** [January 13, 2021, 6:53pm UTC](https://community.auth0.com/t/auth0-integration-with-heroku/56115/3 "2021-01-13T18:53:05Z")

</div>

Hi @pleasehelp,

I’m looking into this now! In order to recreate the error, did you add any environment variable to Heroku or make any changes to the QuickStart code to deploy your app?

Thanks,

Stephanie

---

<div class="post-metadata">

**Author:** ![pleasehelp](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/pleasehelp/32/26873_2.png) [@pleasehelp](https://community.auth0.com/u/pleasehelp)\
**Post date:** [January 13, 2021, 11:37pm UTC](https://community.auth0.com/t/auth0-integration-with-heroku/56115/4 "2021-01-13T23:37:33Z")

</div>

Thanks for the reply. My only environmental variables are the domain and client id. Do I also need to add my API audience url?

---

<div class="post-metadata">

**Author:** ![stephanie.chamblee](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/stephanie.chamblee/32/26087_2.png) [@stephanie.chamblee](https://community.auth0.com/u/stephanie.chamblee)\
**Post date:** [January 14, 2021, 4:29pm UTC](https://community.auth0.com/t/auth0-integration-with-heroku/56115/5 "2021-01-14T16:29:01Z")

</div>

I’m not getting the same `undefined server IP` error, but I was able to deploy an example without setting any environment variables: [https://sjc-react-example.herokuapp.com/](https://sjc-react-example.herokuapp.com/)

In the app, I’m just using the `auth_config.json` file, as I would locally:

```auto
{
  "domain": "<YOUR_DOMAIN>",
  "clientId": "<YOUR_CLIENT_ID>",
  "audience": "<YOUR_API_IDENTIFIER>"
}

```

Something that I was running into while trying to recreate this error is the fact that the QuickStart app runs a React app and API from the same start script. This is a challenge because Heroku dynamically assigns a port to bind to which is accessible with the `process.env.PORT` variable, and so I’m not sure how to listen to `process.env.SERVER_PORT` and `process.env.API_PORT` like it is set up locally.

It looks like there are workarounds for listening to multiple ports in an app deployed to Heroku, but it might be easier to deploy the API separately.

I was able to deploy the Quickstart app on Heroku by updating the `npm start` script to `"node server.js"` and changing `process.env.SERVER_PORT` to `process.env.PORT` in `server.js`. That way I am deploying the React app only.

It sounds like you are facing a different challenge than I did, though. Are you deploying your app from GitHub? Are you seeing the error when you are starting up the app or is it while the app is running (for example, are you seeing the error after attempting to log in to your deployed app)? Are you using the [Heroku Auth0 add-on](https://elements.heroku.com/addons/auth0)?

---

<div class="post-metadata">

**Author:** ![pleasehelp](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/pleasehelp/32/26873_2.png) [@pleasehelp](https://community.auth0.com/u/pleasehelp)\
**Post date:** [January 14, 2021, 11:27pm UTC](https://community.auth0.com/t/auth0-integration-with-heroku/56115/6 "2021-01-14T23:27:17Z")

</div>

I am not using the Auth0 add on. The app launches and functions fine, but when clicking the auth0 login button I am redirected to a page that looks like this [Screenshot - 6b153ab19cb81bda1c08699b0e9b5694 - Gyazo](https://gyazo.com/6b153ab19cb81bda1c08699b0e9b5694). This error only appears on Heroku, and when I run locally I am properly redirected to the Auth0 login page.

---

<div class="post-metadata">

**Author:** ![stephanie.chamblee](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/stephanie.chamblee/32/26087_2.png) [@stephanie.chamblee](https://community.auth0.com/u/stephanie.chamblee)\
**Post date:** [January 15, 2021, 1:47pm UTC](https://community.auth0.com/t/auth0-integration-with-heroku/56115/7 "2021-01-15T13:47:04Z")

</div>

Looking at the screenshot, it looks like the domain is `undefined`

 ![domain](https://global.discourse-cdn.com/auth0/original/3X/b/c/bc29710c5cb18112a75554ece3a0ad8139f094f0.png)

Are you using Heroku environment variables for the domain, or are you using the `auth_config.json` file? It looks like the domain is `undefined` in the Auth0Provider:

```auto
// /src/index.js

ReactDOM.render(
  <Auth0Provider
    domain={config.domain} // <--- This is undefined
    clientId={config.clientId}
    audience={config.audience}
    redirectUri={window.location.origin}
    onRedirectCallback={onRedirectCallback}
  >
    <App />
  </Auth0Provider>,
  document.getElementById("root")
);

```

If you are using the `auth_config` file there, is the file listed in the .gitignore? You could troubleshoot by temporarily hard-coding the domain to see if that resolves the issue.

---

<div class="post-metadata">

**Author:** ![pravin544](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/pravin544/32/26982_2.png) [@pravin544](https://community.auth0.com/u/pravin544)\
**Post date:** [January 16, 2021, 4:28pm UTC](https://community.auth0.com/t/auth0-integration-with-heroku/56115/8 "2021-01-16T16:28:21Z")

</div>

Hi @stephanie.chamblee,

Sorry to jump in middle of convo. I am getting similar issue after deploying into heroku, local works just fine. Is there a source code for sample app you deployed that you can share? Or is there a step by step guide for react+auth0+heroku that you can share?

Thanks

---

<div class="post-metadata">

**Author:** ![pleasehelp](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/pleasehelp/32/26873_2.png) [@pleasehelp](https://community.auth0.com/u/pleasehelp)\
**Post date:** [January 18, 2021, 3:25am UTC](https://community.auth0.com/t/auth0-integration-with-heroku/56115/9 "2021-01-18T03:25:58Z")

</div>

Hi. I’m not sure if you still have the issue but what worked for me was adding missing env variables to Heroku. You can use the cli or go to applications → settings → reveal config variables and add your domain and client\_id. Also thanks for the help Stephanie if you’re reading this.

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/auth0/original/3X/b/5/b560f266932fcce5d57f09a6595bd50518cae3f3.jpeg) [@system](https://community.auth0.com/u/system)\
**Post date:** [February 2, 2021, 3:26am UTC](https://community.auth0.com/t/auth0-integration-with-heroku/56115/10 "2021-02-02T03:26:05Z")

</div>

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.
