Closed AdamCollins closed 5 years ago
Thanks for the complete bug report, I'll try to reproduce later. This does seems like a server.js bug.
Hi @AdamCollins, unfortunately I couldn't reproduce the issue and it works fine for me. Could you please put your package.json
and copy/paste the full error? I suspect one of these 3 issues might be happening:
npm install ejs
. This will make the route throw an error, so it will not render anything and so you'll get this issue.views
folder, which will make an error similar to the one above. This can be changed with the views
option if you want.favicon.ico
, which will not be found. To debug this, add an extra route that does this to see if there's any extra request that you are not intending to make:const server = require("server");
const { get, error } = server.router;
const { render, status } = server.reply;
server([
ctx => {
console.log(ctx.method, ctx.url);
},
get("/", ctx => render("index.ejs"))
]);
There might be some other issue, but these 3 are the ones I'd check for first. I created a repository with working code. Is there anything different from your code?
BTW I strongly believe it is the 3rd option of the browser asking for a resource that cannot be found, because it's the only one that would account for the situation you are seeing that server(get('/', ctx => ...))
does not work but server(ctx => ...)
works.
The issue was option 3. After adding the references to the public folder the warning disappears. Thank you!
Hey @AdamCollins, so I also went ahead and just published 1.0.19
fixing the issue on server.js side. Now the error message will be much more clear like this:
Your middleware did not return anything for this request:
GET /abc.png
This normally happens when no route was matched or if the router did not reply with anything. Make sure to return something, even if it's a catch-all error.
Documentation for reply: https://serverjs.io/documentation/reply/
Relevant issue: https://github.com/franciscop/server/issues/118
Please feel free to open any other issue you find 😄
I am trying to render a simple EJS page(currently doesn't contain any variables) when a user goes to the route directory. The page does render but I get the warning in my title.
From reading this issuehere I thought I may be missing some sort of error handling so I tried adding
to my
server
function but with no prevail.Also, I noticed it does work but if I change my the
server
function to thisbut obviously I would like to have more than one route.
Any help would be appreciated!
Environment (optional):