loopback icon indicating copy to clipboard operation
loopback copied to clipboard

strong-streaming: 404: there is no method to handle Get '/Contact44440484882943s'

Open penzhan8451 opened this issue 11 years ago • 4 comments

I hit by an issue for model rest api. For multi-tenant support, I dynamically created new DS, and models for every user. and Plural is also different for every user. For example, user1 model rest url is like '.../api/UsersAAAAs', user2 will be '.../api/UsersBBBBBs'. My connector module is put to loopbackProj/node-modules.

When user1 and user2 both post a request to create their DS and Models (attach to their DS and APP, model only has different name and plural), user1's model rest api will not be effect, user2 model rest api can work.

Could you please give me any comments? Thanks very much!

sorry for vague description. I paste code here: Step1: User1 send post request, lookback will do:

var ds = server.dataSource(user1_id, dsconfig);
 Account = server.loopback.createModel({
   name: user1_id,
   properties: {
         ...
        },
        options: {
         ...
          plural: user1_id + 's',
          base: 'PersistedModel'
        }

 })

Step2:  Then, User2 send post request:

var ds = server.dataSource(user2_id, dsconfig);
Account = server.loopback.createModel({
   name: user2_id,
   properties: {
         ...
        },
        options: {
         ...
          plural: user2_id + 's',
          base: 'PersistedModel'
        }

 })


   Account.attachTo(ds);
   server.model(Account);

Below is Result:
http://locahost:3000/api/(user2_id + 's') can work, But http://locahost:3000/api/(user1_id + 's') does Not work,

penzhan8451 avatar May 06 '15 12:05 penzhan8451

You might be running into a global model registry issue. I have added a flag to improve support for cases such as yours (multi-tenancy). Can you try using this flag?

Here is how to setup the flag:

var app = loopback({localRegistry: true});

ritch avatar May 06 '15 19:05 ritch

Thanks, I will try.

penzhan8451 avatar May 07 '15 05:05 penzhan8451

@penzhan8451 Did @ritch's solution fix your issue? Can I close this?

superkhau avatar Jul 07 '15 00:07 superkhau

Hi @penzhan8451 Closing issue. If the problem is still persisting, please feel free to leave a comment and I will re-open the issue. Thanks.

loay avatar Apr 07 '16 20:04 loay