As a junior developer i'm facing a problem with koa-static.
I have two graphiQL playground on /private and /admin. The documentation was koa-static serve() from an index.html file (same doc for both).
app.use(serve(path.resolve("./static")));
...
const privateApollo = new ApolloServer(privateApolloConfig as Config);
privateApollo.applyMiddleware({ app, path: "/graphql/private", cors: corsConfig });
const adminApollo = new ApolloServer(adminApolloConfig as Config);
adminApollo.applyMiddleware({ app, path: "/graphql/admin", cors: corsConfig });
I had to create a third apolloServer with a graphiQL playground on /public. Everything is working but i now want to differentiate the documentation for each playground.
I've discovered koa-mount which seems to do exactly that but i cant make it work. I've tried this:
app.use(mount("/graphql/public", serve(path.resolve("./static/graphql/public"))));
app.use(mount("/graphql/admin", serve(path.resolve("./static/graphql/admin"))));
app.use(mount("/graphql/private", serve(path.resolve("./static/graphql/private"))));
Inspiration here : https://stackoverflow.com/a/66377342
Tried multiple variation of the code seen in the stackoverflow link.
app.use(mount("/graphql/public", serve(path.join(__dirname, "./static/graphql/public")))); app.use(mount("/graphql/public", serve("../static/graphql/public"))); app.use(mount("/graphql/public", serve(path.resolve("./static/graphql/public")))); ...