sindresorhus / ky

🌳 Tiny & elegant JavaScript HTTP client based on the Fetch API

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ky in the vite environment request hint cors.

lihe6666 opened this issue · comments

commented

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

commented

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