2
votes

I'm trying to run a custom Foxx app.

Directory structure:

  • ~/src/js/foxx
    • databases
      • _system
        • my_app ( From the docs )
      • test
        • myapp ( My custom app )
          • manifest.json
          • app.js

myapp manifest.json

{
  "name": "myapp",
    "version": "0.0.1",
    "author": "ccraig",
    "controllers": {
      "/": "app.js"
    }
}

myapp app.js

(function() {
 "use strict";

 var Foxx = require("org/arangodb/foxx"),
 controller = new Foxx.Controller(applicationContext);


 controller.get("/", function(req, res) {
   res.set("Content-Type", "text/plain");
   res.body = "Hello world";
   });

}());

command to start server

arangod --javascript.dev-app-path ~/src/js/foxx ~/tmp/arango_db

I then point my browser to:

http://localhost:8529/_db/test/dev/myapp/

and receive this response:

{"error":true,"code":404,"errorNum":404,"errorMessage":"unknown path 'dev/myapp/index.html'"}

The sample app I copied from the docs under _system (my_app) works just fine for me.

I'm also able to run the aardvark admin as well, which is how I created the "test" database. I do notice, though, that it says "inactive" on its icon, while _system says "active", not sure if that's relevant.

Also, in the admin, "myapp" shows up in the the test database's Application list.

1

1 Answers

2
votes

The reason for the 404 is that by default a call to the application root is redirected to "index.html". If "index.html" is no defined route in the app, then the 404 will be raised.

It can be fixed by adding the defaultDocument attribute to the manifest.json file like this:

{
  "name": "myapp",
  "version": "0.0.1",
  "author": "ccraig",
  "controllers": {
    "/": "app.js"
  },
  "defaultDocument" : ""
}

Btw I found this in the manual: http://docs.arangodb.org/Foxx/HandlingRequest.html

Please note that even after changing your manifest file your browser may have cached the redirection, so it will may route you to index.html. Closing the browser or clearing its cache might fix this.