IP and URL based authentication
Unanswered
Kurilian Bobtail posted this in #help-forum
Kurilian BobtailOP
I have a case where I want to change UI based on url and/or ip of requesting user.
Ex. My page is https://www.mywebsite.com/signin
This page is called from http://www.myblog.com/tech/nextjs
In nextjs blog there is one link which is pointing to my page ie. https://www.mywebsite.com/signin
My requirement
When someone is coming to my page from different origin then I should know from where the request is coming to render signin page.
Based on the ip or url value my UI on signin changes
What i have tried
I have tried middleware but in middleware I am getting my own ip and my own website path ie., https://www.mywebsite.com/signin
Instead of that i need referer of caller website and ip.
Ex. My page is https://www.mywebsite.com/signin
This page is called from http://www.myblog.com/tech/nextjs
In nextjs blog there is one link which is pointing to my page ie. https://www.mywebsite.com/signin
My requirement
When someone is coming to my page from different origin then I should know from where the request is coming to render signin page.
Based on the ip or url value my UI on signin changes
What i have tried
I have tried middleware but in middleware I am getting my own ip and my own website path ie., https://www.mywebsite.com/signin
Instead of that i need referer of caller website and ip.
3 Replies
Kurilian BobtailOP
Please note above mentioned links are not mine. I have added them just for example purpose
Tonkinese
What about getting the referrer from the headers?
const headersList = headers()
const referer = headersList.get('referer')
const headersList = headers()
const referer = headersList.get('referer')
Kurilian BobtailOP
I tried that in middleware.
But still it is not giving me origin url and ip. its still giving details of my app
e.g. https://www.mywebsite.com/signin in our example
But still it is not giving me origin url and ip. its still giving details of my app
e.g. https://www.mywebsite.com/signin in our example