sindresorhus / ky

🌳 Tiny & elegant JavaScript HTTP client based on the Fetch API
MIT License
13.62k stars 363 forks source link

ky in the vite environment request hint cors. #521

Closed lihe6666 closed 1 year ago

lihe6666 commented 1 year ago

ky in the vite environment request hint cors.

ky version: 0.33.3 vite version: 4.4.9

error

1692685302201

vite.config.ts

1692685364053

but, i use fetch is correct

i will headers remove from ky.create and add attribute mode = 'no-cors'

1692688019737

marpme commented 1 year ago

In order to make use of your proxy, your request URL must be relative.

So instead of making the request with ky.get("http://my.live.server.com/smallApps/), you can make use of ky.get("/smallApps/").

This would mean in local-development the request goes to http://localhost:5147 and is handled by your proxy and in production (assuming it's running the same domain) the request goes http://my.live.server.com.

In case you want to configure the base URL manually (via JS), you can make use of ky prefix-url option