How to display error if backend not available during Rules / Actions?

Hi there,

For my application (React / Golang), I’m using Auth0 with a Social authentification (using Github), and to create the user account into my database (and to do some init on this account like sending an e-mail, generating some settings and so one), I used the custom rules / flows.

So I implement the Post login flow with a custom action, that will send a callback to my API (with a specific token), including the user informations in the request.

My question is : now when my backend is not available, Auth0 will send a lot of request (infinite loop), and I can see it in my logs. I want to avoid this case.

There is a way to return an error with this custom rule, of display a Auth0 default page, or something like this, to avoid this infinite loop ? I can’t find anything related to this in the example provided.

This is my Rules / Action content :

exports.onExecutePostLogin = async (event, api) => {
  const axios = require('axios');

  await axios.post('https://mybackend.endpoint.fr', event.user,
                   { headers: { 'Authorization': MY_SECRET_TOKEN }}
                  );          
};

Thanks in advance for your help,

Regards,
Florian