Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Outlook link preview breaking "one time URL"

Tags:

php

token

outlook

I made a one time URL system, that has a token that becomes invalid once the user accesses that URL.

I send the email to the client with the URL containing the token, when he commits a form.

It works fine for people who uses Gmail and whatnot. However, many of the clients who use Hotmail complained that always when they clicked the URL even for the first time, it was already invalid.

I ended up finding out that Outlook has a Link Preview function, enabled by default, that display a little preview of the links in the email. Since this function accesses the URL once, the token becomes invalid when the client opens the email.

Is there a way in PHP to detect if the access to a URL is being done by a link preview system? That way I could make the token invalid only when the access was not made by a link preview.

like image 748
Leandro Batista Avatar asked Sep 06 '25 02:09

Leandro Batista


1 Answers

The outlook preivew request is using HEAD request here. You can check the request type and do not invalidate your link with HEAD request.

(A better solution will be stopping triggering any logic with a simple GET request. You can create a button instead of link to ask users to click. Preview bot is unlikely to click a button like users.)

like image 187
jilykate Avatar answered Sep 07 '25 21:09

jilykate