My server has a javascript file, I only want to allow a certain web sites from being able to run it. I know the few sites that may use it.
In ASP.NET MVC, or ASP.NET Core, how can I restrict the javascript from being sent to a rogue web site?
My server has a javascript file, I only want to allow a certain web sites from being able to run it. I know the few sites that may use it.
In ASP.NET MVC, or ASP.NET Core, how can I restrict the javascript from being sent to a rogue web site?
you can't 100% avoid it, but you could check window.location to see if the origin matches.
if (location.origin.toLowerCase() !== 'http://example.com') {
// you can't use me
}