mirror of
https://github.com/usememos/memos.git
synced 2025-03-23 14:10:08 +01:00
chore: update request base url
This commit is contained in:
parent
be899cd027
commit
15c90871d9
@ -62,6 +62,8 @@ func NewServer(ctx context.Context, profile *profile.Profile, store *store.Store
|
|||||||
AllowMethods: []string{http.MethodGet, http.MethodHead, http.MethodPut, http.MethodPatch, http.MethodPost, http.MethodDelete},
|
AllowMethods: []string{http.MethodGet, http.MethodHead, http.MethodPut, http.MethodPatch, http.MethodPost, http.MethodDelete},
|
||||||
}))
|
}))
|
||||||
|
|
||||||
|
e.Use(CORSMiddleware())
|
||||||
|
|
||||||
e.Use(middleware.TimeoutWithConfig(middleware.TimeoutConfig{
|
e.Use(middleware.TimeoutWithConfig(middleware.TimeoutConfig{
|
||||||
Skipper: timeoutSkipper,
|
Skipper: timeoutSkipper,
|
||||||
Timeout: 30 * time.Second,
|
Timeout: 30 * time.Second,
|
||||||
@ -184,3 +186,31 @@ func timeoutSkipper(c echo.Context) bool {
|
|||||||
// Skip timeout for blob upload which is frequently timed out.
|
// Skip timeout for blob upload which is frequently timed out.
|
||||||
return c.Request().Method == http.MethodPost && c.Request().URL.Path == "/api/v1/resource/blob"
|
return c.Request().Method == http.MethodPost && c.Request().URL.Path == "/api/v1/resource/blob"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func CORSMiddleware() echo.MiddlewareFunc {
|
||||||
|
return func(next echo.HandlerFunc) echo.HandlerFunc {
|
||||||
|
return func(c echo.Context) error {
|
||||||
|
if grpcRequestSkipper(c) {
|
||||||
|
return next(c)
|
||||||
|
}
|
||||||
|
|
||||||
|
r := c.Request()
|
||||||
|
w := c.Response().Writer
|
||||||
|
|
||||||
|
w.Header().Set("Access-Control-Allow-Origin", r.Header.Get("Origin"))
|
||||||
|
w.Header().Set("Access-Control-Allow-Methods", "GET, POST, PUT, DELETE, OPTIONS")
|
||||||
|
w.Header().Set("Access-Control-Allow-Headers", "Content-Type, Authorization")
|
||||||
|
w.Header().Set("Access-Control-Allow-Credentials", "true")
|
||||||
|
|
||||||
|
// If it's preflight request, return immediately.
|
||||||
|
if r.Method == "OPTIONS" {
|
||||||
|
w.WriteHeader(http.StatusOK)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Continue processing request.
|
||||||
|
next(c)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -10,7 +10,7 @@ import { WebhookServiceDefinition } from "./types/proto/api/v2/webhook_service";
|
|||||||
import { WorkspaceServiceDefinition } from "./types/proto/api/v2/workspace_service";
|
import { WorkspaceServiceDefinition } from "./types/proto/api/v2/workspace_service";
|
||||||
|
|
||||||
const channel = createChannel(
|
const channel = createChannel(
|
||||||
window.location.origin,
|
import.meta.env.VITE_API_BASE_URL || window.location.origin,
|
||||||
FetchTransport({
|
FetchTransport({
|
||||||
credentials: "include",
|
credentials: "include",
|
||||||
}),
|
}),
|
||||||
|
@ -1,6 +1,9 @@
|
|||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
import { Resource } from "@/types/proto/api/v2/resource_service";
|
import { Resource } from "@/types/proto/api/v2/resource_service";
|
||||||
|
|
||||||
|
axios.defaults.baseURL = import.meta.env.VITE_API_BASE_URL || window.location.origin;
|
||||||
|
axios.defaults.withCredentials = true;
|
||||||
|
|
||||||
export function getSystemStatus() {
|
export function getSystemStatus() {
|
||||||
return axios.get<SystemStatus>("/api/v1/status");
|
return axios.get<SystemStatus>("/api/v1/status");
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user