Yeah exactly; the headers are such a pain to set up!
https://github.com/vitejs/vite/issues/3909
For deployment it's a different story then but for example netlify has a quite intuitive way to set headers for CORS:
https://github.com/padenot/ringbuf.js/blob/master/public/_he...