nango icon indicating copy to clipboard operation
nango copied to clipboard

Env variable to customize the redirect URL

Open gailuron1964 opened this issue 3 years ago • 3 comments

I'm trying to deploy pizzly on a single machine that hosts both my backend, frontend and the pizzly-server.

I want to avoid opening a port dedicated to pizzly and was planning instead to use nginx to redirect all traffic on port 443 to the /oauth prefix path to pizzly-server.

Unfortunately, this approach breaks because of how the redirect url is computed:

export function getPort() {
    return process.env['SERVER_PORT'] != null ? +process.env['SERVER_PORT'] : 3004;
}

export function getOauthCallbackUrl() {
    let port = getPort();
    return (process.env['SERVER_HOST'] || 'http://localhost') + `:${port}` + '/oauth/callback';
}

For my use-case, I want the pizzly server to run on port 3004, but I want the getOauthCallbackUrl to point to port 443, since the proxy server handles redirection of traffic.

One solution would be to add a new OAUTH_CALLBACK_URL environment variable and have pizzly server use that if defined. Would that be a good idea ?

Happy to provide a fix if the env variable approach is OK.

gailuron1964 avatar Dec 12 '22 16:12 gailuron1964

This is a great thing to add, please feel free to add it anytime.

There was actually a AUTH_CALLBACK_URL in the .env file prior to the recent rewrite (cf. code).

bastienbeurier avatar Dec 12 '22 20:12 bastienbeurier

#280

gailuron1964 avatar Dec 13 '22 09:12 gailuron1964

Resolved by https://github.com/NangoHQ/Pizzly/pull/280

bastienbeurier avatar Dec 13 '22 09:12 bastienbeurier