SoftInstigate / restheart

Rapid API Development with MongoDB
https://restheart.org
GNU Affero General Public License v3.0
807 stars 171 forks source link

Mount static resource to "/" blocks mongo mounts #431

Closed austinrappa78 closed 2 years ago

austinrappa78 commented 2 years ago

When upgrading to v6 the static resource path now blocks any mongo-mounts within the same path.

Expected Behavior

With RESTHeart running:

  1. The website www.blahblahblah.com serves up static content from static-resources-mounts
  2. The website www.blahblahblah.com/api serves the MongoDB collections

Current Behavior

The website www.blahblahblah.com serves up static content from static-resources-mounts The website www.blahblahblah.com/api returns 404 errors

Context

Upgrading from v3 to v6 and this behavior has changed.

Environment

Assume the folder structure:

In the restheart.yml configuration file:

mongo-mounts:
    - what: "*"
      where: /api

static-resources-mounts:
    - what: /www
      where: /
      welcome-file: index.html
      secured: false
      embedded: false

Steps to Reproduce

Make changes to restheart.yml. Use curl or postman.

ujibang commented 2 years ago

The way services bind to URIs has changed from version 3.

You need to set the uri option of the service parameter as follows:

# this allows mapping urls to mongodb resources, but the root URI is set by the plugins-args.mongo.uri parameter
mongo-mounts:
  - what: "*"
    where: /

static-resources-mounts:
    - what: /www
      where: /
      welcome-file: index.html
      secured: false
      embedded: false

# this binds the MongoService to the root URI /api
plugins-args:
  mongo:
    uri: /api
austinrappa78 commented 2 years ago

Thanks, I don't see that documented anywhere or the documentation wasn't clear enough. https://restheart.org/docs/v4/upgrade-to-v4/ https://restheart.org/docs/v5/upgrade-to-v5/ https://restheart.org/docs/upgrade-to-v6/