/console/console.js 404 when using prefix
See original GitHub issueHi,
When I set prefix
to /cloudcmd
and press the console button, devtool shows a 404
for /cloudcmd/console/console.js
.
The cause is that cloudcmd is prepending prefix
to "/console"
as prefix
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 changing prefix + '/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?
Issue Analytics
- State:
- Created 5 years ago
- Comments:16 (8 by maintainers)
Top Results From Across the Web
node.js - Router.use() requires a middleware function but got ...
I am beginner to use socket.io with NodeJS and mocha. ... Non-existent API routes should return 404, not the HTML page router.use((_req, ...
Read more >Discord.js Per Server Prefix Error "TypeError: Cannot read ...
Hi i was making a per server prefix thing for my discord.js v12 bot using quick.db everything was going well but when using...
Read more >Router tutorial: tour of heroes - Angular
A wildcard route can navigate to a custom "404 Not Found" component or ... route when the remaining URL begins with the redirect...
Read more >puppeteer-core@19.4.1 - jsDocs.io
An example of using JavaScript and CSS coverage to get percentage of ... to null if waiting for hidden: true and xpath is...
Read more >Console features reference - Chrome Developers
It assumes that you're already familiar with using the Console to view logged messages and run JavaScript. If not, see Get Started.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Regarding
express mount point
, there is app.baseUrl. You are right that client side still need to know the prefix, that’s why I say server side: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 believe the current way this middleware works has the same effect of mounting in most cases, but there’s still some use cases I can think of where it does not satisfy:
/${name}
, and expect them to work. It doesn’t know theprefix
way.app.use(['/cloudcmd', '/admin'], cloudcmd({..}))
. Theprefix
way doesn’t benefit from it.I’m not familiar with the client code right now. It’s possible that I missed something. 😄
You didn’t reproduce it because you’re running it as a standalone app, by executing
cloudcmd --prefix /cloudcmd
, or using it as a middleware at the root path. However, as I mentioned above, when you use the mounting feature of express with cloudcmd, this issue comes in, because express strips thebaseUrl
for you. I highly recommend making cloudcmd work with mounting if you offer its functionality as a middleware, because it’s a very common pattern in express. With it you allow the middleware to work on any path without telling it the prefix. To repro the issue, use the following code: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
prefix
tricks in server side source code down the stack(console-io, etc.) I believe. I appreciate it if you can consider my advice.