johnpapa / lite-server

Lightweight node server
MIT License
2.31k stars 267 forks source link

Handling CORS #78

Open masious opened 8 years ago

masious commented 8 years ago

Hi. I want to communicate with another server. Is there a way so that I can send Access-Control-Allow-Origin: * header to my client?

Laureian commented 8 years ago

You have to add sending it from your server manually. In which language your server is written? For example if you're using .net with web .api there is nice tutorial: http://www.asp.net/web-api/overview/security/enabling-cross-origin-requests-in-web-api

factoidforrest commented 7 years ago

@Laureian The server is liteserver...

@masious Did you ever find an answer for this? How to set the lite-server headers? I feel like it might be part of bs-config but I can't find the option.

ikbelkirasan commented 6 years ago

Create a file called bs-config.json in your working directory and it should have cors key set to true.

{
  "cors": true
}

Restart lite-server and it should work.

ifsheldon commented 1 year ago

As of Firefox 107.0.1, the method of setting bs-config.json is not working but perhaps it's the issue of Firefox since Chrome 108.0.5359.94 does not have this issue when "cors" is set.

So, if anyone encounter this issue on Firefox in your development, consider using a more permissive browser as well when you have no clue why CORS problem persists