Skip to main content

Is there a way to allow zaps to define which URL to use for authentication and API calls? Using the app designer + env variables gives the “Only absolute URLs are supported” error, so I guess that’s out.

Hi @Qobo 

When you get the “Only absolute URLs are supported” error, it means that you’re using a relative URL path. You can use environment variables to set the base URL to use, then concatenate the base and relative URLs to construct the complete path. e.g.

z.request({
url: process.env.BASE_URL + "/user/profile",
// ...
})

Tips:

-  When you want to make it easy for you to change the API URL without having to update it in each trigger or action, you can define it as an environment variable from the Advanced -> Environment section and in your code, you can reference it as process.env.API_URL (if you set the variable name to API_URL).

Example:

z.request({ 
url: process.env.API_URL + "/user/profile",
// ...
})

 

-  If you want to prompt the user for their API URL so that each user connects to a different API server, you will need to add an authentication field to store it then you will be able to reference it as bundle.authData.api_url (if the field key is api_url)

Example:

z.request({ 
url: bundle.authData.api_url + "/user/profile",
// ...
})

 

Note: Zapier will throw the error "Only absolute URLs are supported" if the API base URL is not defined because in that case, it will only see the path name part of the URL (e.g. /user/profile ).


@ikbelkirasan perfect, thanks!


@ikbelkirasan can I do the same via the UI builder? I am doing something like this and getting absolute url error while testing the authentication 

 

 


@sanchitsharma hi! Did the variable on the UI mode work?


@sanchitsharma - I’ve just seen your comment! Yes, that’s possible and you’re probably getting that error because you didn’t define BACKEND_URL in the environment variables page.

 


Thanks @ikbelkirasan , sorry for trouble, yes I had defined the BACKEND_URL in advanced options but somehow it had not been saved.

@Pmaojo 

Once declared it works.

Real neat, the whole Zapier development environment.