Showing different data based on referer
Answered
Tonkinese posted this in #help-forum
TonkineseOP
Hey,
Can I use the referer url for detecting on which domain the user accesses my site? Like if he uses domain1.de or domain.xyz?
So I could replace data on the page based on the domain?
Can I use the referer url for detecting on which domain the user accesses my site? Like if he uses domain1.de or domain.xyz?
So I could replace data on the page based on the domain?
Answered by riský
you should be able to just use the
(also note that a common method for supporting this is using rewrites to /[host]/things to be able to be dynamic)
host header (also note that a common method for supporting this is using rewrites to /[host]/things to be able to be dynamic)
13 Replies
@Tonkinese Hey,
Can I use the referer url for detecting on which domain the user accesses my site? Like if he uses domain1.de or domain.xyz?
So I could replace data on the page based on the domain?
you should be able to just use the
(also note that a common method for supporting this is using rewrites to /[host]/things to be able to be dynamic)
host header (also note that a common method for supporting this is using rewrites to /[host]/things to be able to be dynamic)
Answer
TonkineseOP
Okay thank you 🙂
So this should work on vercel with multiple domains?
well what are you trying to do?
like allow users to have their own custom domains and show their content?
or you just have many localization?
TonkineseOP
Like If I visit with firstnamelastname.xyz i want my name to show on the page and if it is my Online Name it should show my online name. Like adjusting my portfolio for the used domain
@Tonkinese So this should work on vercel with multiple domains?
but yeah if you add them to the vercel project they should all work, then if you either read the header via page or use rewrites and view the param it should work
TonkineseOP
Okay thank you friend 🙂
I am going to message you if it is solved
so basically i think these 2 options should work:
1. use the host header and https://nextjs.org/docs/app/api-reference/next-config-js/rewrites#header-cookie-and-query-matching
2. but if its a really simple change it may be easier to just use next/headers to view, but i wouldnt advice this as much as it cant be static
1. use the host header and https://nextjs.org/docs/app/api-reference/next-config-js/rewrites#header-cookie-and-query-matching
2. but if its a really simple change it may be easier to just use next/headers to view, but i wouldnt advice this as much as it cant be static
TonkineseOP
Okay thank you