404 error on /email-verification

My production app is getting a 404 error on http://localhost:3001/email-verification http://localhost:3001/health generates {"status":"ok"} Using the same source when I run "wasp start" locally /email-verification works fine. I have copied the /src/auth/ from a new template.
11 Replies
kapa.ai
kapa.ai5mo ago
Hi @alphadog2584. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave: ---------------------- A 404 error on http://localhost:3001/email-verification in production suggests that you are trying to access a client-side route directly on the server port. In Wasp, the server (typically on port 3001) handles API and backend routes, while the client (React app, typically on port 3000) handles frontend routes like /email-verification. When you visit /email-verification in your browser, you should be accessing it via the client (e.g., http://localhost:3000/email-verification), not the server. The server (port 3001) will return 404 for any route that is not an API endpoint or static asset, which is expected behavior. Why does it work locally? When running locally with wasp start, the development server (Vite) serves the React app on port 3000, and all client-side routes are handled correctly. If you access http://localhost:3000/email-verification, it works because the React router takes over. If you access http://localhost:3001/email-verification, you will get a 404, which is normal. What should you do? - Make sure you are accessing the client app (React) on the correct port (usually 3000), not the server port (3001). - In production, ensure your deployment setup serves the built React app as the frontend, and that client-side routes are handled by the frontend server, not the backend API server. Relevant documentation: - The /email-verification route should be defined in your main.wasp file and point to a React page/component, which is then handled by the client app, not the server API. See the example route setup here: Add the Routes and Pages. - The email verification flow expects the user to land on a client route, not a server route: Email Verification Flow. Summary:
Access /email-verification via your client app (port 3000 or your production frontend URL), not the backend server (port 3001). A 404 on the server for this route is expected and not an error in your Wasp setup. If you need to serve the frontend and backend from the same domain in production, ensure your deployment is configured to route client-side paths to the React app, not the backend API server. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ---------------------- Sorry @alphadog2584, 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?
alphadog2584
alphadog2584OP5mo ago
Boom! Thank you @kapa.ai what are all the server endpoints?
kapa.ai
kapa.ai5mo ago
Let me check the knowledge base for you again. One moment! :books: ---------------------- Wasp server endpoints are primarily defined by: 1. Custom HTTP API Endpoints:
You can declare custom API endpoints in your main.wasp file using the api declaration. Each API endpoint specifies an HTTP method and path, for example:
api fooBar {
fn: import { fooBar } from "@src/apis",
httpRoute: (GET, "/foo/bar")
}

api fooBar {
fn: import { fooBar } from "@src/apis",
httpRoute: (GET, "/foo/bar")
}

This would create a server endpoint at /foo/bar for GET requests. You can define as many such endpoints as you need, with different methods and paths. The implementation of each endpoint is a NodeJS function that receives Express's req, res, and a Wasp context object.
Custom HTTP API Endpoints 2. Custom Express Routes via Server Setup:
You can add arbitrary Express routes in your server setup function, for example:
export const mySetupFunction = async ({ app }) => {
app.get('/customRoute', (_req, res) => {
res.send('I am a custom route')
})
}

export const mySetupFunction = async ({ app }) => {
app.get('/customRoute', (_req, res) => {
res.send('I am a custom route')
})
}

This adds a GET endpoint at /customRoute on the server.
Server Config: Adding a Custom Route 3. Built-in Endpoints:
Wasp may provide some built-in endpoints, such as /health for health checks, but the knowledge sources do not provide a comprehensive list of all built-in endpoints. How to List All Endpoints?
There is currently no built-in Wasp command or documentation feature that automatically lists all server endpoints for your app. You define them explicitly in your main.wasp file (via api declarations) and in your server setup code (via Express routes).
API Reference Summary:
- All server endpoints are those you declare via api in main.wasp and any custom Express routes you add in your server setup. - There is no automatic endpoint listing feature in Wasp at this time. - Built-in endpoints like /health may exist, but are not comprehensively documented in the provided sources. If you need a full list, review your main.wasp for api declarations and your server setup code for custom routes. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ---------------------- Sorry @alphadog2584, 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?
alphadog2584
alphadog2584OP5mo ago
@kapa.ai shouldnt there be a /auth endpoint? I dont see that as a api or route
MEE6
MEE65mo ago
Wohooo @alphadog2584, you just became a Waspeteer level 2!
kapa.ai
kapa.ai5mo ago
Let me check the knowledge base for you again. One moment! :books: ---------------------- Wasp does not require you to manually define a /auth endpoint in your main.wasp file as an api or route. The authentication system in Wasp (including login, signup, and related flows) is handled internally by Wasp when you enable auth in your app configuration. These endpoints are generated automatically and are not visible as custom api or route declarations in your project files. For example, when you enable username and password authentication in your main.wasp file:
app myApp {
wasp: {
version: "^0.13.0"
},
title: "My App",
auth: {
userEntity: User,
methods: {
usernameAndPassword: {},
},
onAuthFailedRedirectTo: "/login"
}
}
app myApp {
wasp: {
version: "^0.13.0"
},
title: "My App",
auth: {
userEntity: User,
methods: {
usernameAndPassword: {},
},
onAuthFailedRedirectTo: "/login"
}
}
Wasp will automatically provide the necessary backend endpoints for authentication (such as login, signup, etc.), but these are not exposed for customization or listed as api or route entries in your code. You only need to define the frontend pages (e.g., /login, /signup) as routes for the React app, not for the backend server Auth Overview Username & Password Auth. So, it is expected that you do not see a /auth endpoint as an api or route in your project files. The auth endpoints are managed by Wasp internally. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ---------------------- Sorry @alphadog2584, 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?
alphadog2584
alphadog2584OP5mo ago
I had another docker which presented 3001 as the path within port 3000. I had a block in there which was trying to forward /email-verification to port 3001. I removed it and now it works. Took me 4 hours to work that out.
Carlos
Carlos5mo ago
Hey @alphadog2584 sorry I'm just checking the questions now for today. Has you problem been solved?
alphadog2584
alphadog2584OP5mo ago
@Carlos Yeah, very impressed the bot fixed it so quickly
alphadog2584
alphadog2584OP5mo ago
@Carlos Are you open to helping me with some tricky parts of my SaaS for some money?
Carlos
Carlos5mo ago
hey @alphadog2584, sorry, i'm not able to, working for Wasp (the company) is already my full-time job 😊 but you might want to post at #🕵jobboard-wasp-devs

Did you find this page helpful?