about custom route
Does anyone try add a custom route follow the docs? Does not work for me. My res message not show up. The page is a nav bar with a blank background
10 Replies
hey James, you are referring to adding a custom API route?
Hey, not sure waht you are referring to -> is it about frontend route (
route MyRoute { ...
, in main.wasp), or is it API route (api SomeApi {...
in main.wasp)?
Pls share a bit more about what you tried (code example) and explain what didn't work (what you expected, what happened).for main.wasp i add
server:{
setupFn: import { mySetupFunction } from "@server/myServerSetupCode.js",
},
in my myServerSetupCode.ts I add
import { ServerSetupFn, Application } from '@wasp/types'
export const mySetupFunction: ServerSetupFn = async ({ app }) => {
addCustomRoute(app)
}
function addCustomRoute(app: Application) {
app.get('/customRoute', (_req, res) => {
res.send('I am a custom route')
})
}`
this is what I getI follow this page
https://wasp-lang.dev/docs/project/server-config#adding-a-custom-route
I expected this should be a blank page response "I am a custom route" only, instead it show the nav bar and a blank background. and for every page the response is the same
what I want to do is to create a custom route for me to handle,
like this :
Wohooo @james, you just became a Waspeteer level 1!
@martinsos
My fault, checking the wrong page
@james ah sorry for being so late with the response -> great you figured it out!
What is not great on our side is that we just have a blank page, we have to improve that.
Any idea what else we could have done to possibly prevent the issue you had? Has Wasp or us somehow made it easy to shoot yourself in the foot here?
I just look the wrong port. Setup on server, but looking client. It is all fine now. Thank you so much