В настоящее время я использую API Unspla sh (сторонний), чтобы получить случайную фотографию для расширения chrome, которое я строю. Используя fetch, я могу попасть в конечную точку и получить фотографию, но продолжаю получать это предупреждение в консоли chrome:
A cookie associated with a cross-site resource at http://unsplash.com/ was set without the SameSite attribute. A future release of Chrome will only deliver cookies with cross-site requests if they are set with SameSite=None and Secure. You can review cookies in developer tools under Application>Storage>Cookies and see more details at https://www.chromestatus.com/feature/5088147346030592 and https://www.chromestatus.com/feature/5633521622188032.
Вот мой код
background.js
// Request for image resource
fetch(url, {
mode: "cors",
// credentials: "include", I used include before and it gave me errors
headers: {
"Content-Type": "application/json"
}
})
// received image resource and now need to jsonify the response
.then(function(result) {
return result.json();
})
// Grab key value from json
.then(function(photo) {
let photoImage = photo.urls.full;
// set storage
chrome.storage.sync.set({ background: photoImage }, function(result) {});
})
Я понимаю, что это запрос cors, поэтому я должен как-то установить свой запрос на "SameSite = None" и "Secure".