Question:
Do relative paths work with Algolia redirects?
Answer:
Yes. If you are adding custom data for instance, you can add any data as long as it is in a JSON format. For a redirect, what matters more is how you use this custom data on the front-end.
For example, in the code snippet in this guide, you can see there is a "redirect" attribute in the custom data for the rule which looks like this:
{
objectID: 'a-rule-id',
condition: {
pattern: 'star wars',
anchoring: 'is'
},
consequence: {
userData: {
redirect: 'https://www.google.com/#q=star+wars'
}
}
};
On the front-end, this snippet is used to see if there are any "redirect' fields on the custom data. If there are, then window.location.href is set to it:
const match = items.find(data => Boolean(data.redirect));
if (match && match.redirect) {
window.location.href = match.redirect;
}
Since you should be able to use window.location.href to set both relative and absolute path, there should be no issue here.