1

I have a link to default email verification function in Firebase. Using this link from the browser works fine, however it fails when being used from server side with the following code:

  try {
    const url = `https://example.com/__/auth/action?mode=verifyEmail&oobCode=${oobCode}&apiKey=${apiKey}&lang=en`;
 
    const response = await axios.get(url);
    
    if (response.data.success) {
      return next();
    } else {
        return next(new ErrorResponse("Failed email verification", FORBIDDEN));
    }
  } catch (error) {
    return sendFailedWithErr(res, error.message);
  }

When I am copying the URL used in the server side the exact same URL works from the browser, but fails on the server side. Would appreciate any idea what is the problem.

1 Answer 1

1

This is because a call to this URL is not going to return a response that you can check like the response of a REST API endpoint with, e.g. response.data.success.

As you will see here, this URL is supposed to be used to open a web page in which you will:

  1. Get the values passed as QueryString parameters (e.g. mode or oobCode)
  2. Call, from the web page some methods of the Firebase JavaScript SDK, like applyActionCode() in the case of email verification.

You may be able to mimic this action from a server, but I've never tried.

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you Renaud Tarnec. I took your answer from stackoverflow.com/questions/67091834/…

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.