Why doesn't console.log output anything to terminal?
I am trying to debug cors middleware setup. In main.wasp I have:
In ServerSetup.ts for testing I have:
Since I see no output it looks like
serverMiddlewareFn
is never called.3 Replies
Hi @Sam79. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
----------------------
Based on the information provided, it seems like you have correctly set up the
serverMiddlewareFn
in your ServerSetup.ts
file and correctly referenced it in your main.wasp
file.
However, it's important to note that the serverMiddlewareFn
is a global middleware configuration function that modifies the middleware stack for all operations and APIs. This means that it will only be called when an operation or API request is made that goes through the middleware stack.
If you're not seeing any output from the console.log
statement in your serverMiddlewareFn
, it could be because no such requests are being made, or there might be an error occurring before the middleware function gets called.
To debug this, you could try making a request to your server that should go through the middleware stack and see if the console.log
statement gets executed then.
If you're still not seeing any output, there might be an error occurring elsewhere in your code that's preventing the middleware function from being called. You could try checking the server logs for any error messages or exceptions that might give you a clue as to what's going wrong.
If you're still having trouble, you might want to consider opening an issue on the Wasp GitHub page (https://github.com/wasp-lang/wasp/issues) to get help from the Wasp community.
Sources:
- Server Config > Middleware Config Function (https://wasp-lang.dev/docs/project/server-config#middleware-config-function)
- Advanced > Configuring Middleware > 1. Customize Global Middleware (https://wasp-lang.dev/docs/advanced/middleware-config#1-customize-global-middleware)
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------
Sorry @Sam79, I seem to be having a bit of trouble. Don't worry though, I've pinged my support and they will try to fix me up! :technologist:
Perhaps try again in 15mins?Where are you looking for the logs? In the terminal or in the browser console?
I did this:
and
and here's the output: