Created
July 13, 2021 15:08
-
-
Save masone/530520eeb4e69afa2bdb41aaddaacda9 to your computer and use it in GitHub Desktop.
First-party onetrust cookie
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { parseCookies, setCookie as setNookie } from "nookies" | |
const onetrustFirstPartyHandler = (req, res, next) => { | |
const cookies = parseCookies({ req }) | |
const setCookie = (name) => { | |
const value = cookies[name] | |
if (value) { | |
setNookie({ res }, name, value, { | |
httpOnly: false, | |
maxAge: 365 * 24 * 60 * 60, | |
path: "/", | |
sameSite: "lax", | |
}) | |
} | |
} | |
;["OptanonConsent", "OptanonAlertBoxClosed", "eupubconsent-v2"].forEach( | |
setCookie | |
) | |
next() | |
} | |
export default onetrustFirstPartyHandler |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment