Viscision
Viscision5mo ago

Auth Provider Discovery Failed

Has anyone recieved this error while self-hosting? I am using coolify to host convex and my front-end is a next.js app. Everything has been working with my app before when I was using convex cloud but I wanted to try self hosting instead and now I keep getting this error when trying to register/login/check if a user is authenticated. I obscured the url for security reasons. Any ideas would be great! Returning false from isAuthenticated because Error: {"code":"AuthProviderDiscoveryFailed","message":"Auth provider discovery of https://%2A%2A%2A%2A%2A/http failed: 404 Not Found
24 Replies
Convex Bot
Convex Bot5mo ago
Thanks for posting in <#1088161997662724167>. Reminder: If you have a Convex Pro account, use the Convex Dashboard to file support tickets. - Provide context: What are you trying to achieve, what is the end-user interaction, what are you seeing? (full error message, command output, etc.) - Use search.convex.dev to search Docs, Stack, and Discord all at once. - Additionally, you can post your questions in the Convex Community's <#1228095053885476985> channel to receive a response from AI. - Avoid tagging staff unless specifically instructed. Thank you!
erquhart
erquhart5mo ago
Have you tried the auth debug steps? https://docs.convex.dev/auth/debug
Debugging Authentication | Convex Developer Hub
You have followed one of our authentication guides but something is not working.
Viscision
ViscisionOP5mo ago
Yea nothing seems to work
Viscision
ViscisionOP5mo ago
When I try to register an account or log in I do get these in the chrome console
No description
Viscision
ViscisionOP5mo ago
Auth should be completely working as it was 100% working when I was using convex cloud idk if I am just missing something or a step with convex auth and self hosting but I followed the guide exactly This is my middleware.ts file for next.js
import {
convexAuthNextjsMiddleware,
createRouteMatcher,
nextjsMiddlewareRedirect,
} from "@convex-dev/auth/nextjs/server";

const isAuthPage = createRouteMatcher(["/auth(.*)"]);
const isProtectedRoute = createRouteMatcher(["/games(.*)", "/leaderboard(.*)"]);

export default convexAuthNextjsMiddleware(async (request, { convexAuth }) => {
if (isAuthPage(request) && (await convexAuth.isAuthenticated())) {
return nextjsMiddlewareRedirect(request, "/games");
}
if (isProtectedRoute(request) && !(await convexAuth.isAuthenticated())) {
return nextjsMiddlewareRedirect(request, "/");
}
});

export const config = {
// The following matcher runs middleware on all routes
// except static assets.
matcher: ["/((?!.*\\..*|_next).*)", "/", "/(api|trpc)(.*)"],
};
import {
convexAuthNextjsMiddleware,
createRouteMatcher,
nextjsMiddlewareRedirect,
} from "@convex-dev/auth/nextjs/server";

const isAuthPage = createRouteMatcher(["/auth(.*)"]);
const isProtectedRoute = createRouteMatcher(["/games(.*)", "/leaderboard(.*)"]);

export default convexAuthNextjsMiddleware(async (request, { convexAuth }) => {
if (isAuthPage(request) && (await convexAuth.isAuthenticated())) {
return nextjsMiddlewareRedirect(request, "/games");
}
if (isProtectedRoute(request) && !(await convexAuth.isAuthenticated())) {
return nextjsMiddlewareRedirect(request, "/");
}
});

export const config = {
// The following matcher runs middleware on all routes
// except static assets.
matcher: ["/((?!.*\\..*|_next).*)", "/", "/(api|trpc)(.*)"],
};
Viscision
ViscisionOP5mo ago
And this shows up in my next.js npm run dev terminal after attempting to register/login
No description
erquhart
erquhart5mo ago
Can you share the rest of the error in that last screenshot The beginning part has the actual error message
Viscision
ViscisionOP5mo ago
It was too long had to upload as a txt file hope that is fine
Viscision
ViscisionOP5mo ago
This maybe be helpful too so I will post it. On ly convex dashboard settings for URL & Deploy keys I have these so I created the CONVEX_SITE_URL environment variable matching that url and it seems that from that error message it is trying to hit that http actions url
No description
Viscision
ViscisionOP5mo ago
And here is the authentication settins on my convex dashboard, this url matches the CONVEX_SITE_URL
No description
Viscision
ViscisionOP5mo ago
I also tried manually opening this url and entering my admin token and it does says 404
No description
erquhart
erquhart5mo ago
What domain is in your auth.config.ts? That's the Convex dashboard 404 html printed out in the error, which makes me think the auth domain is convex.dev or a subdomain of convex.dev. You can dm if you want to keep it private
Viscision
ViscisionOP5mo ago
Okay thanks! I will send you a dm
radix
radix4mo ago
I have this exact same problem Have you found a solution?
Viscision
ViscisionOP4mo ago
I have not found a solution for this. I gave up for the time being I may try again soon though. If you figure it out though I would love to hear how
radix
radix4mo ago
Actually it works now I sent a patch to both coolify and dokploy they merged so you can use either, it was because both were using older versions of convex
Viscision
ViscisionOP4mo ago
@radix Did you need to open any ports on your vps for convex to work with coolify? I saw your pull request and manually created the docker compose file to see if that worked for me but I'm still running into that same issue It may also be my environment variables using the wrong url or something simple
radix
radix4mo ago
I didn't need to open any ports on my VPS. Right now I am using dokploy but I can send you my docker compose if you want
Kazumi
Kazumi4mo ago
I feel somehow middleware is not able to act (I am going through a similar issue if not the same) completely for the authentication thus nextjs is trying to hit an otherwise expected endpoint such as api/auth instead. I think we try to provide convexAuth before it is ready. May be something to think about in the docu tutorial where we all get our reference from.
Viscision
ViscisionOP4mo ago
Would you be able to sent me your docker compose file?
radix
radix4mo ago
Yup ENV VARS:
NEXT_PUBLIC_DEPLOYMENT_URL=https://api.convex.MYDOMAIN
CONVEX_CLOUD_ORIGIN=https://api.convex.MYDOMAIN
CONVEX_SITE_ORIGIN=https://convex.MYDOMAIN
NEXT_PUBLIC_DEPLOYMENT_URL=https://api.convex.MYDOMAIN
CONVEX_CLOUD_ORIGIN=https://api.convex.MYDOMAIN
CONVEX_SITE_ORIGIN=https://convex.MYDOMAIN
Then in Dokploy
services:
backend:
image: ghcr.io/get-convex/convex-backend:5143fec81f146ca67495c12c6b7a15c5802c37e2
ports:
- "${PORT:-3210}:3210"
- "${SITE_PROXY_PORT:-3211}:3211"
volumes:
- data:/convex/data
environment:
- INSTANCE_NAME=${INSTANCE_NAME:-}
- INSTANCE_SECRET=${INSTANCE_SECRET:-}
- CONVEX_RELEASE_VERSION_DEV=${CONVEX_RELEASE_VERSION_DEV:-}
- ACTIONS_USER_TIMEOUT_SECS=${ACTIONS_USER_TIMEOUT_SECS:-}
- CONVEX_CLOUD_ORIGIN=${CONVEX_CLOUD_ORIGIN:-http://127.0.0.1:3210}
- CONVEX_SITE_ORIGIN=${CONVEX_SITE_ORIGIN:-http://127.0.0.1:3211}
- DATABASE_URL=${DATABASE_URL:-}
- DISABLE_BEACON=${DISABLE_BEACON:-}
- REDACT_LOGS_TO_CLIENT=${REDACT_LOGS_TO_CLIENT:-}
- RUST_LOG=${RUST_LOG:-info}
- RUST_BACKTRACE=${RUST_BACKTRACE:-}
- POSTGRES_URL=${POSTGRES_URL:-}
- DO_NOT_REQUIRE_SSL=1
healthcheck:
test: curl -f http://localhost:3210/version
interval: 5s
start_period: 5s

dashboard:
image: ghcr.io/get-convex/convex-dashboard:5143fec81f146ca67495c12c6b7a15c5802c37e2
ports:
- "${DASHBOARD_PORT:-6791}:6791"
environment:
- NEXT_PUBLIC_DEPLOYMENT_URL=${NEXT_PUBLIC_DEPLOYMENT_URL:-http://127.0.0.1:3210}
depends_on:
backend:
condition: service_healthy

volumes:
data:
services:
backend:
image: ghcr.io/get-convex/convex-backend:5143fec81f146ca67495c12c6b7a15c5802c37e2
ports:
- "${PORT:-3210}:3210"
- "${SITE_PROXY_PORT:-3211}:3211"
volumes:
- data:/convex/data
environment:
- INSTANCE_NAME=${INSTANCE_NAME:-}
- INSTANCE_SECRET=${INSTANCE_SECRET:-}
- CONVEX_RELEASE_VERSION_DEV=${CONVEX_RELEASE_VERSION_DEV:-}
- ACTIONS_USER_TIMEOUT_SECS=${ACTIONS_USER_TIMEOUT_SECS:-}
- CONVEX_CLOUD_ORIGIN=${CONVEX_CLOUD_ORIGIN:-http://127.0.0.1:3210}
- CONVEX_SITE_ORIGIN=${CONVEX_SITE_ORIGIN:-http://127.0.0.1:3211}
- DATABASE_URL=${DATABASE_URL:-}
- DISABLE_BEACON=${DISABLE_BEACON:-}
- REDACT_LOGS_TO_CLIENT=${REDACT_LOGS_TO_CLIENT:-}
- RUST_LOG=${RUST_LOG:-info}
- RUST_BACKTRACE=${RUST_BACKTRACE:-}
- POSTGRES_URL=${POSTGRES_URL:-}
- DO_NOT_REQUIRE_SSL=1
healthcheck:
test: curl -f http://localhost:3210/version
interval: 5s
start_period: 5s

dashboard:
image: ghcr.io/get-convex/convex-dashboard:5143fec81f146ca67495c12c6b7a15c5802c37e2
ports:
- "${DASHBOARD_PORT:-6791}:6791"
environment:
- NEXT_PUBLIC_DEPLOYMENT_URL=${NEXT_PUBLIC_DEPLOYMENT_URL:-http://127.0.0.1:3210}
depends_on:
backend:
condition: service_healthy

volumes:
data:
Viscision
ViscisionOP4mo ago
Thanks a ton for this! Finally auth is working
radix
radix4mo ago
Haha that's great!

Did you find this page helpful?