简体   繁体   中英

Accept server only GET request

I'm making an GET request to my server with AJAX+JS. I'm using it to delete file like this:

delete.php?file_id=0123456789&user=555555

When I send GET request delete.php will delte file with ID 0123456789, but is there a way to accept only request that server makes to itself.

For example if user opens new tab and types www.mysite.com/delete.php?file_id=0123456789 server will decline that request, but if I call it with JS function server will accept the request.

How about using X-XSRF-TOKEN in combination with Angular JS?

This will require your webapplication to generate and check this token, but your AJAX request will be authenticated.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM