cors - Slim Framework, Rest Api routes structure in folders need to call options for each API -
i have developed api runs routes on folders instead of single file routes(as people does), before modifing api structure need find out why need call options every time call different api, understand cors concept , working on server/clientbut don´t understand why call options, normal or have map routes in single file? if case affects have routes mapped on single call or better way have separated apis on diferent folders?
this way in slim, calls api "users" included in "document_root -> v2 -> users -> index.php", inside index.php call slimframework engine , api calls this:
users api called at: api.host.com/v2/users/ host.com/v2/users/ = document_root -> v2-> users -> read.php post host.com/v2/users/ = document_root -> v2-> users -> add.php put host.com/v2/users/ = document_root -> v2-> users -> edit.php in index.php:
// read $app->get('/', function () use ($api) { include 'read.php'; }); // add $app->post('/', function () use ($api) { include 'add.php'; }); // update $app->put('/', function () use ($api) { include 'edit.php'; }); , on...
preflight requests e.g. options part of cors standard. in general preflight request sent if cors request uses other request method get, head or post. also, if post used send request data content-type other application/x-www-form-urlencoded, multipart/form-data, or text/plain request preflighted.
when doing apis application/json requests means requests preflighted.
Comments
Post a Comment