mirror of
https://github.com/dstotijn/hetty.git
synced 2025-07-01 18:47:29 -04:00
Enforce trailing slashes on API paths
This ensures that the Next.js app works consistently both when running in dev mode as well as when it has been exported to static HTML/JS.
This commit is contained in:
@ -6,8 +6,8 @@ module.exports = withCSS({
|
|||||||
async rewrites() {
|
async rewrites() {
|
||||||
return [
|
return [
|
||||||
{
|
{
|
||||||
source: "/api/:path",
|
source: "/api/:path/",
|
||||||
destination: "http://localhost:8080/api/:path", // Matched parameters can be used in the destination
|
destination: "http://localhost:8080/api/:path/",
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
},
|
},
|
||||||
|
@ -8,7 +8,7 @@ function createApolloClient() {
|
|||||||
return new ApolloClient({
|
return new ApolloClient({
|
||||||
ssrMode: typeof window === "undefined",
|
ssrMode: typeof window === "undefined",
|
||||||
link: new HttpLink({
|
link: new HttpLink({
|
||||||
uri: "/api/graphql",
|
uri: "/api/graphql/",
|
||||||
}),
|
}),
|
||||||
cache: new InMemoryCache({
|
cache: new InMemoryCache({
|
||||||
typePolicies: {
|
typePolicies: {
|
||||||
|
@ -81,11 +81,11 @@ func main() {
|
|||||||
hostname, _ := os.Hostname()
|
hostname, _ := os.Hostname()
|
||||||
host, _, _ := net.SplitHostPort(req.Host)
|
host, _, _ := net.SplitHostPort(req.Host)
|
||||||
return strings.EqualFold(host, hostname) || (req.Host == "hetty.proxy" || req.Host == "localhost:8080")
|
return strings.EqualFold(host, hostname) || (req.Host == "hetty.proxy" || req.Host == "localhost:8080")
|
||||||
}).Subrouter()
|
}).Subrouter().StrictSlash(true)
|
||||||
|
|
||||||
// GraphQL server.
|
// GraphQL server.
|
||||||
adminRouter.Path("/api/playground").Handler(playground.Handler("GraphQL Playground", "/api/graphql"))
|
adminRouter.Path("/api/playground/").Handler(playground.Handler("GraphQL Playground", "/api/graphql/"))
|
||||||
adminRouter.Path("/api/graphql").Handler(handler.NewDefaultServer(api.NewExecutableSchema(api.Config{Resolvers: &api.Resolver{
|
adminRouter.Path("/api/graphql/").Handler(handler.NewDefaultServer(api.NewExecutableSchema(api.Config{Resolvers: &api.Resolver{
|
||||||
RequestLogService: reqLogService,
|
RequestLogService: reqLogService,
|
||||||
}})))
|
}})))
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user