Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

154
Views
How to verify that an API Request is coming from my Javascript on my Site?

I have some JS on my website which requests Data from my own PHP API and the API request data from external APIs (Google, YT etc.)

How can my own PHP API can verify, that the request is from MY Javascript and not from someone else?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

If all you want to do is to simply prevent people from accessing your API through JS on other sites you can just set the CORS header Access-Control-Allow-Origin to your own domain.

header("Access-Control-Allow-Origin: your.domain.here");

Note that this doesn't mean people can't access your API through direct calls using software like Postman, python scripts etc.

If, for example, you want only yourself and/or specific users to be able to access the API you could look into php session management. This way you can create accounts which are allowed to access specific data on your API.

You could also use API keys to allow users to directly communicate with your API if needed.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!