set new path for proxy pass and location, with slash in the end of paths
This commit is contained in:
@@ -97,5 +97,6 @@ networks:
|
||||
web-network:
|
||||
driver: bridge
|
||||
internal:
|
||||
driver: bridge
|
||||
app-network:
|
||||
name: serv_golang_rest_api_app-network
|
||||
|
||||
@@ -31,8 +31,8 @@ server {
|
||||
}
|
||||
|
||||
# New location for REST API
|
||||
location /api {
|
||||
proxy_pass http://api:8080;
|
||||
location /api/ {
|
||||
proxy_pass http://api:8080/;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
|
||||
@@ -4,8 +4,8 @@ package middleware
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"strings"
|
||||
"serv_golang_rest_api/internal/utils"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func AuthMiddleware(next http.Handler) http.Handler {
|
||||
|
||||
@@ -2,6 +2,7 @@ package server
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"serv_golang_rest_api/internal/handlers"
|
||||
"serv_golang_rest_api/internal/middleware"
|
||||
@@ -37,9 +38,15 @@ func (s *Server) configureRouter(db *gorm.DB) {
|
||||
|
||||
// API routes
|
||||
s.router.Route("/v1", func(r chi.Router) {
|
||||
s.router.Get("/check", s.healthCheck)
|
||||
r.Get("/check", s.healthCheck)
|
||||
s.setupUserRoutes(r, db)
|
||||
})
|
||||
|
||||
// Для отладки - выводим все маршруты
|
||||
chi.Walk(s.router, func(method string, route string, handler http.Handler, middlewares ...func(http.Handler) http.Handler) error {
|
||||
fmt.Printf("[%s] %s\n", method, route)
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
func (s *Server) setupUserRoutes(r chi.Router, db *gorm.DB) {
|
||||
@@ -50,9 +57,6 @@ func (s *Server) setupUserRoutes(r chi.Router, db *gorm.DB) {
|
||||
authHandler := &handlers.AuthHandler{DB: db}
|
||||
oauthHandler := &handlers.OAuthHandler{DB: db}
|
||||
|
||||
// Health check
|
||||
r.Get("/health", s.healthCheck)
|
||||
|
||||
// Публичные маршруты
|
||||
r.Route("/auth", func(r chi.Router) {
|
||||
r.Post("/register", authHandler.Register)
|
||||
|
||||
Reference in New Issue
Block a user