Ky: How to set Response headers?

Created on 2 Aug 2019  路  1Comment  路  Source: sindresorhus/ky

I'm using this library in React js. Right now I'm facing cors error for the particular URL.
It might be possible that cors are not set from the server side but I want to pass response headers to see if it works or not.

Most helpful comment

Sorry but this does not appear to be an issue with Ky. We would be happy answer your general help questions over on Stack Overflow. Could you please post this question there?

The short answer is that you need to send a CORS request with Ky and then the server needs to respond with the appropriate headers. Ky does not control the response headers because it is not a server. If you simply want to see what the response headers are, then you should use your browser's Network tab in the developer tools to inspect the request and response.

Sending CORS requests with Ky is identical to how it is done with fetch. I strongly suggest reading MDN's article on CORS as it may give you some insight into what is wrong.

https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS

If you need further assistance, please post on Stack Overflow with a code sample and the details of the headers from the Network tab.

>All comments

Sorry but this does not appear to be an issue with Ky. We would be happy answer your general help questions over on Stack Overflow. Could you please post this question there?

The short answer is that you need to send a CORS request with Ky and then the server needs to respond with the appropriate headers. Ky does not control the response headers because it is not a server. If you simply want to see what the response headers are, then you should use your browser's Network tab in the developer tools to inspect the request and response.

Sending CORS requests with Ky is identical to how it is done with fetch. I strongly suggest reading MDN's article on CORS as it may give you some insight into what is wrong.

https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS

If you need further assistance, please post on Stack Overflow with a code sample and the details of the headers from the Network tab.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

kirillgroshkov picture kirillgroshkov  路  3Comments

davalapar picture davalapar  路  6Comments

Splact picture Splact  路  7Comments

fruitraccoon picture fruitraccoon  路  4Comments

rohmanhm picture rohmanhm  路  6Comments