1

I'm trying to configure fusebox so that it serves my app in root but also an API (for testing only) with /api.

With webpack I managed to get this with the following

devServer: {
    setup: function (app) {
      app.use('/api', jsonServer.router('db.json'));
    }
  }

so when I get to http://localhost:8080 I get my app index.html, but when I type http://localhost:8080/api I get the contents of db.json, so I can mock an API Rest that returns json data.

In fusebox I'm using this:

fuse.dev(server => {
  const app = server.httpServer.app;
  app.use('/api', jsonServer.router('db.json'));
});

and my app is being served in http://localhost:4444, but when I try http://localhost:4444/api, there's nothing. I tried this:

fuse.dev({ root: false }, server => {
  const app = server.httpServer.app;
  app.use('/api', jsonServer.router('db.json'));
});

And then the API works in http://localhost:4444/api, but then I can´t get to http://localhost:4444, so I can´t load my app.

What am I doing wrong? Thanks.

David
  • 3,364
  • 10
  • 41
  • 84

1 Answers1

0

I figured it out.

It seems that when a new route is defined you HAVE to also define the root. So this will do:

fuse.dev({ root: 'dist' }, server => {
  const app = server.httpServer.app;
  app.use('/api', jsonServer.router('db.json'));
});
David
  • 3,364
  • 10
  • 41
  • 84