I am working with appid-serversdk-nodejs and I have the code working and everything works fine, both locally and in the IBM cloud.
But I have to manually switch the APP-URL (localhost:3000 vs .eu-gb.mybluemix.net) I understand that I can do it without providing the passport settings, but how can I have one code base that works for:
- localdev test
- instance in ibm cloud
- production instance in ibm cloud
I am talking about this piece of code:
// The redirectUri value can be supplied in three ways:
// 1. Manually in new WebAppStrategy({redirectUri: "...."})
// 2. As environment variable named redirectUri
// 3. If none of the above was supplied the App ID SDK will try to retrieve
// application_uri of the application running on IBM Cloud and append a
// default suffix "/ibm/bluemix/appid/callback"
passport.use(new WebAppStrategy({
tenantId: "removed",
clientId: "removed",
secret: "removed",
oauthServerUrl: "https://eu-gb.appid.cloud.ibm.com/oauth/v4/REMOVED"
redirectUri: "https://REMOVED.eu-gb.mybluemix.net" + CALLBACK_URL
//redirectUri: "http://localhost:3000" + CALLBACK_URL
}));
Update: I have moved the data to the .env file, but this doesn't solve my question.
tenantId: process.env.APPID_tenantId,
clientId: process.env.APPID_clientId,
secret: process.env.APPID_secret,
oauthServerUrl: process.env.APPID_oauthServerUrl,
redirectUri: process.env.APPID_redirectUri + CALLBACK_URL
Now I have to change the .env file, which leads to a new commit and build. I want to leverage the connection between APP-ID and our Node server in the IBM cloud.
I am getting errors if I don't supply the redirectUri or the entire WebAppStrategy