@AdilBa

Почему проблема с cors не исчезла?

Я сделал API на go gin и поставил его на серве. Фронтэнд пытался вызывать ручки, но выходила ошибка cors. Погуглил и добавил github.com/gin-contrib/cors, на время это помогло, но позже снова повилась.
Вот пример кода:
func (h *Handler) InitRoute() *gin.Engine {
	router := gin.New()

	router.Use(cors.Default())

        router.POST("/test", h.test)

	return router
}


Вот ошибка с фронта:
Access to XMLHttpRequest at '123:8000/auth/sign-in' from origin 'localhost:3000' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: The value of the 'Access-Control-Allow-Origin' header in the response must not be the wildcard '*' when the request's credentials mode is 'include'. The credentials mode of requests initiated by the XMLHttpRequest is controlled by the withCredentials attribute
  • Вопрос задан
  • 278 просмотров
Пригласить эксперта
Ответы на вопрос 2
@calculator212
Для cors лучше свои хендлеры писать, будет проще потом работать
Ответ написан
Комментировать
@falconandy
В ошибке с фронта всё же написано - читайте внимательнее

The value of the 'Access-Control-Allow-Origin' header in the response must not be the wildcard '*' when the request's credentials mode is 'include'. The credentials mode of requests initiated by the XMLHttpRequest is controlled by the withCredentials attribute
Ответ написан
Комментировать
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы