Let us assume that we have a public API, for example, company.com/publicEndpoint, that can accept requests from any source. Various websites, like foo.com and bar.com, use JavaScripts that call this endpoint to retrieve a list of strings, among other things.
Is there a secure way for company.com/publicEndpoint to ensure that only requests from foo.com or bar.com (and not from zzz.com) are allowed (of course only via browser)? We could use referer or origin, but these HTTP headers can be easily overwritten or modified. I am searching for an approach that allows us to "fingerprint" the request so that it is almost impossible to fake a request coming from foo.com or bar.com.
Is it feasible to achieve this using only the frontend, without implementing a token system with a backend on foo.com or bar.com?