Web Connection
Detect if a request is coming from a server or a browser
Gravatar is a globally recognized avatar based on your email address. Detect if a request is coming from a server or a browser
  Carl Chambers
  All
  Oct 31, 2022 @ 02:46pm

Hey Rick,

My app for this question serves API requests.
Is there a reliable way to determine if an API request is coming from a server vs an AJAX request directly from a browser?
I have a case where I may want to provide the requested data only for AJAX requests (with the necessary CORS header) but not for requests from a server.

Can this be done?

Thanks,
Carl

Gravatar is a globally recognized avatar based on your email address. re: Detect if a request is coming from a server or a browser
  Rick Strahl
  Carl Chambers
  Oct 31, 2022 @ 03:12pm

No.

Any HTTP client can spoof any HTTP headers - that's kind of the point of HTTP 😄 IOW I can pick up the user agent string from Edge or Chrome and then use that with a call from wwHttp.

+++ Rick ---

Gravatar is a globally recognized avatar based on your email address. re: Detect if a request is coming from a server or a browser
  Carl Chambers
  Rick Strahl
  Oct 31, 2022 @ 04:02pm

That's what I figured but I thought I'd check.
Thanks, Rick.

Carl

© 1996-2022