feat: add cors header

This commit is contained in:
Sosokker 2025-02-02 05:16:51 +07:00
parent 3f62e9c5d8
commit 5cb05709dd

View File

@ -131,10 +131,16 @@ func readCoordData(filepath string, coordCh chan<- Coordinate) {
close(coordCh)
}
// https://www.stackhawk.com/blog/golang-cors-guide-what-it-is-and-how-to-enable-it/
func enableCors(w *http.ResponseWriter) {
(*w).Header().Set("Access-Control-Allow-Origin", "*")
}
// lat, lon, rain+place
// state-id, rainfall (scale 100)
func rawDataHandler(w http.ResponseWriter, r *http.Request) {
enableCors(&w)
apiKey := loadEnv()
coordCh := make(chan Coordinate)