You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
header('Access-Control-Allow-Headers: accept, content-type, authorization'); header('Access-Control-Allow-Methods: GET,POST,OPTIONS,DELETE,PUT'); header('Access-Control-Allow-Origin: *'); if ("OPTIONS" === $_SERVER['REQUEST_METHOD']) { return; }
Používám v index.php hned na začátku tohle, ty allow headers si uprav podle toho, co potřebuješ
nenapadá někoho proč mi nefunguje CORS? potřebuji se k api dostat z jquery
`
public function actionCreate()
{
$response = $this->getHttpResponse();
$response->addHeader('Access-Control-Allow-Origin', "");
$response->addHeader('Access-Control-Allow-Methods', "");
$response->addHeader('Access-Control-Allow-Headers', 'X-Requested-With');
`
zdá se že nette nevrací správné hlavičky
tady je jquery požadavek
`
(function ($) {
$.ajaxPost = function (url, data, success) {
var ajaxSettings = {
url: url,
method: "POST",
data: JSON.stringify(data),
contentType: "application/json; charset=utf-8",
crossDomain: true,
dataType: "json",
success: function (result)
{
if (result.status !== "ok") {
alert("Napodařilo se provést požadované úpravy!");
}
`
díky za tipy jak tohle řešíte
The text was updated successfully, but these errors were encountered: