This commit is contained in:
2026-02-18 02:53:15 +03:00
parent 8e0419c56b
commit d16b38e6e1
2 changed files with 11 additions and 0 deletions

View File

@@ -34,6 +34,12 @@ func main() {
router := router.New()
router.Handle("OPTIONS /", func(w http.ResponseWriter, r *http.Request) error {
w.WriteHeader(200)
fmt.Fprintf(w, "ok")
return nil
})
router.Handle("POST /auth/register", func(w http.ResponseWriter, r *http.Request) error {
var body struct {
Email string `json:"email"`

View File

@@ -32,6 +32,11 @@ func (router *router) SendJSON(w http.ResponseWriter, data any) error {
func (router *router) Handle(pattern string, handler func(w http.ResponseWriter, r *http.Request) error) {
router.mux.HandleFunc(pattern, func(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Access-Control-Allow-Credentials", "true")
w.Header().Set("Access-Control-Allow-Origin", "http://localhost:3000")
w.Header().Set("Access-Control-Allow-Methods", "GET,POST,PATCH,DELETE,OPTIONS")
w.Header().Set("Access-Control-Allow-Headers", "Content-Type,Content-Length")
if err := handler(w, r); err != nil {
router.SendJSON(w, struct {
Error string `json:"error"`