# Companion server not working properly

**URL:** <https://community.transloadit.com/t/companion-server-not-working-properly/16532>\
**Category:** Uppy\
**Created:** [March 8, 2023, 6:15am UTC](https://community.transloadit.com/t/companion-server-not-working-properly/16532 "2023-03-08T06:15:28Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![tanmay-kali](https://yyz2.discourse-cdn.com/flex032/user_avatar/community.transloadit.com/tanmay-kali/32/812_2.png) [@tanmay-kali](https://community.transloadit.com/u/tanmay-kali)\
**Post date:** [March 8, 2023, 6:15am UTC](https://community.transloadit.com/t/companion-server-not-working-properly/16532/1 "2023-03-08T06:15:28Z")

</div>

```auto
const express = require("express");
const bodyParser = require("body-parser");
const cors = require("cors");
const session = require("express-session");
const companion = require("@uppy/companion");
const app = express();
const port = 3002;
app.use(bodyParser.json());
app.use(function (req, res, next) {
  res.header("Access-Control-Allow-Origin", "*");
  res.header("Access-Control-Allow-Methods", "GET,PUT,POST,DELETE,OPTIONS");
  res.header(
    "Access-Control-Allow-Headers",
    "Content-Type, Authorization, Content-Length, X-Requested-With, uppy-auth-token"
  );

  // allows cors preflighting
  if ("OPTIONS" === req.method) {
    res.sendStatus(200);
  }
  // Move to next middleware
  else {
    next();
  }
});
app.use(session({ secret: "secret", resave: false, saveUninitialized: false }));

const options = {
  providerOptions: {
    drive: {
      key: "",
      secret: "",
    },
  },
  server: {
    host: "localhost:3002",
    protocol: "http",
    // This MUST match the path you specify in `app.use()` below:
    path: "/companion",
  },
  filePath: "files",
  secret: "secret",
  sendSelfEndpoint: "localhost:3002",
  debug: true,
};

const { app: companionApp, emitter } = companion.app(options);

app.use("/companion", companionApp);

app.get("/", (req, res) => {
  res.send("Hello World!");
});

const server = app.listen(port);

emitter.on("upload-start", ({ token }) => {
  console.log("Upload started", token);

  function onUploadEvent({ action, payload }) {
    if (action === "success") {
      emitter.off(token, onUploadEvent); // avoid listener leak
      console.log("Upload finished", token, payload.url);
    } else if (action === "error") {
      emitter.off(token, onUploadEvent); // avoid listener leak
      console.error("Upload failed", payload);
    }
  }
  emitter.on(token, onUploadEvent);
});
companion.socket(server);

```

This is my settings , I am unable to get companion to work at all . From frontend I keep getting this error GET [http://localhost:3002/drive/list/root](http://localhost:3002/drive/list/root) 404 (Not Found)

---

<div class="post-metadata">

**Author:** ![Merlijn](https://yyz2.discourse-cdn.com/flex032/user_avatar/community.transloadit.com/merlijn/32/1382_2.png) [@Merlijn](https://community.transloadit.com/u/Merlijn)\
**Post date:** [March 8, 2023, 9:48am UTC](https://community.transloadit.com/t/companion-server-not-working-properly/16532/2 "2023-03-08T09:48:32Z")

</div>

Hi, you request goes to `/drive/list/root` but your Companion instance is under `/companion`, thus resulting in a 404.
