-
-
Notifications
You must be signed in to change notification settings - Fork 259
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
/console/console.js 404 when using prefix #200
Comments
I do not know why you receive
I can not reproduce this, in debugger I see such result: Could you please tell me what version of node and express are you use? |
You didn't reproduce it because you're running it as a standalone app, by executing
Currently it only works by:
I recommend it to be:
It not only makes it easier to use, but also easier to implement, I guess, because you only deal with logical paths within your middleware. You can eliminate most of the |
I understand what are you talking about, would be great to see it as a pull request :). And would be great to understand how to test it as well :) |
I'm willing to contribute. I'll try when I have free time. 😄 |
OK, there is a couple things that should be considered. When you do not set prefix directly client side of Cloud Commander doesn't know the place to lazy load data from. We should determine how to get In this case: app.use('/cloudcmd', cloudcmd({
socket,
config: {
prefix: ''
}
})); client/load-module which is used to load When you use: app.use('/cloudcmd', cloudcmd({
socket,
config: {
prefix: '/cloudcmd'
}
})); And use only prefix config('console') && konsole({
prefix: '/console',
online,
}); The it has a wrong prefix to load data from, only What you want is a good idea, but we should think how to implement such behavior correctly :). Could you please tell me how do you use app.use(cloudcmd({
socket,
config: {
prefix: '/cloudcmd'
}
})); Maybe we can find another way for your case that will be much simpler :). The thing is all this stuff with prefixes made to avoid conflicts between if (url.indexOf(prefix))
return next(); made for this purpose :). |
Regarding
The client code doesn't need change the way they work. They keep prepending the prefix when they request resources, it's just no longer specified by the user of the middleware.
I'm not familiar with the client code right now. It's possible that I missed something. 😄 |
Added support of Anyways you still need to set prefix for web sockets, we can change the way of doing things like this: app.use(cloudcmd({
config, // config data (optional)
plugins, // optional
modules, // optional
}));
cloudcmd.listen(prefix, socket);
server.listen(port); in next major release. But it is two api calls, instead of one :). |
This issue is fixed in v11.6.0, 😄, but seems
?
|
Yes, there is a need to set a prefix for web sockets. So as I said prefix should be generated or added with: cloudcmd.listen(prefix, socket); In next major release. Anyways I do not think that it is a big problem to duplicate prefix with mount point, it is not very beautiful, but it works as expected. (req, res, next) => {
// set prefix from req.baseUrl
} not a very good place for validation as well, because it is a network request. Do you have any ideas how to make things more simple and obvious? |
Yes, I tend to agree with you. Call of socket listen should happen at the moment the server start to listen, but there seems no way for a middleware to be notified of this kind of event. I can't think of a better way either, so I can accept the duplicate. |
There is one more thing we can do about this, we can add one more conception In this case there will be no need to use app.use('/cloudcmd', cloudcmd({
config: {
prefixSocket: '/cloudcmd' // optional
prefix: '/cloudcmd', // will not be used if there is a mount point
}
})) Now |
Do you mean removing |
That is right |
Line 182 in 51ee377
|
You absolutely right, and it is already translated to mounting point :). And with help of v11.7.0 you can use app.use('/cloudcmd', cloudcmd()); |
You're so quick. 😄. Will have a try. |
Hi,
When I set
prefix
to/cloudcmd
and press the console button, devtool shows a404
for/cloudcmd/console/console.js
.The cause is that cloudcmd is prepending
prefix
to"/console"
asprefix
for console-io:https://github.com/coderaiser/cloudcmd/blob/v11.5.3/server/cloudcmd.js#L143-L146
When it goes to console-io,
https://github.com/cloudcmd/console-io/blob/v9.0.0/server/index.js#L103
it will not work as it seems, because
req.url
will be"/console/console.js"
instead of"/cloudcmd/console/console.js"
due to the mounting feature of express. I tried changingprefix + '/console'
to'/console'
and it works.I didn't read further in console-io, so I'm not sure if it'll break things in console-io. Can you take a look?
The text was updated successfully, but these errors were encountered: