Mansoor
Mansoor12mo ago

https 404 not found

import { httpRouter } from 'convex/server' import { httpAction } from './_generated/server' const http = httpRouter() http.route({ path: '/test', method: 'GET', handler: httpAction(async (ctx, request) => { try { const resll = await request.json() console.log(resll) // const data = await ctx.runMutation(internal.user.register, body) // console.log(data) return new Response(null, { status: 200, }) } catch (err) { console.error(err) return new Response('something went wrong', { status: 400, }) } }), }) ------------------------------------------------------ Status 404 VersionHTTP/2 Transferred191 B (58 B size) Referrer Policystrict-origin-when-cross-origin Request PriorityHighest DNS ResolutionSystem
5 Replies
ballingt
ballingt12mo ago
What URL are you requesting? What file is this code in?
lee
lee12mo ago
is it possible you're missing the line export default http; ?
Mansoor
MansoorOP12mo ago
import { httpRouter } from 'convex/server' import { httpAction } from './_generated/server' const http = httpRouter() export const test = http.route({ path: '/test', method: 'GET', handler: httpAction(async (ctx, request) => { try { const resll = await request.json() console.log(resll) // const data = await ctx.runMutation(internal.user.register, body) // console.log(data) return new Response(null, { status: 200, }) } catch (err) { console.error(err) return new Response('something went wrong', { status: 400, }) } }), }) added export and tested same problem const response = await fetch( https://${CONVEX_DEPLOYMENT_URL}.convex.site/test ) fetch calling from client side iam doing export const test = code code is in the "https.ts" file
ballingt
ballingt12mo ago
Move it to http.ts and default export the router, export default http
Mansoor
MansoorOP12mo ago
ok, i got it, thank you

Did you find this page helpful?