Content-Typeをちゃんと指定しないとダメだった。
バージョン
php
# php -v
PHP 5.3.3 (cli) (built: Mar 22 2017 12:27:09)
Copyright (c) 1997-2010 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies
Firefox
55.0.3
https://www.mozilla.org/en-US/firefox/55.0.3/releasenotes/
ダメだったやつ
fetch(
url,
{
method: 'POST',
mode: 'cors',
body: 'key1=value1&key2=value2'
}
).then(function(response) {
console.log(response);
}).catch(function(e) {
console.error(e);
});
OKだったやつ
fetch(
url,
{
method: 'POST',
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
mode: 'cors',
body: 'key1=value1&key2=value2'
}
).then(function(response) {
console.log(response);
}).catch(function(e) {
console.error(e);
});