I have a simple Firebase Cloud Function to redirect to a URL. The code is here:
export const redirect_url = functions.https.onRequest((request, response) => {
var redirect_url = request.query.redirect_url as string;
functions.logger.info(`Redirect URL = ${redirect_url}`, {structuredData: true});
response.redirect(redirect_url);
});
This works perfectly when I redirect to my website like this (note the actual firebase project domain is hidden):
https://us-central1-<PRIVATE>.cloudfunctions.net/redirect_url?redirect_url=https://wealdcreative.com
But when I try to redirect to an Instagram AR filter it goes to a permissions page on Google's AppEngine.
https://us-central1-<PRIVATE>.cloudfunctions.net/redirect_url?https://www.instagram.com/ar/3357317521220189/
The page states: An application is requesting permission to access your Google Account
I guess Instagram
is not allowing the redirect or I need to tell Firebase to allow the instagram.com
domain.
Does anyone know what the solution is here?
UPDATE:
The logs tell me that my escaped version of the URL has not passed in parsed and is undefined
. This is the escaped URL:
https://www.instagram.com/ar/3357317521220189/
It should unescape to: https://www.instagram.com/ar/3357317521220189/
So this is something to do with why this is not being passed through as a query string.
I tested the cloud function with the unescaped URL in the body of the function and not a query param. It worked and opened the Instagram filter page in the browser.
CodePudding user response:
There's a syntax error in your second URL:
.../redirect_url?https://www.instagram.com/ar/3357317521220189/
should be:
.../redirect_url?redirect_url=https://www.instagram.com/ar/3357317521220189/