I have a Directus instance (backend) hosted on a heroku dyno that is working fine.
I have a custom frontend developed with Qwik city. Everything is working fine locally (dev and build), but when I try to deploy it either on Cloudflare pages or Vercel edge it is failing.
I get a 500 error on every routes and the error logs are really unhelpful.
I only get:
Error: e is not a function
on Vercel and the little variant Error: t is not a function
on Cloudflare pages.
The error comes from the Directus client, here is the file (https://github.com/directus/examples/blob/main/astro/src/utils/get-directus-client.js):
import { Directus } from '@directus/sdk'
import { backendConfig } from '@config/backend.config'
import type { BackendDirectusTypes } from '@shared/types/backend/directus.types'
export const getDirectusClient = async () => {
const {
directusPublicUrl,
directusEmail,
directusPassword,
directusStaticToken,
} = backendConfig
const directus = new Directus<BackendDirectusTypes>(directusPublicUrl)
if (await directus.auth.token) return directus
if (directusEmail && directusPassword) {
await directus.auth.login({
email: directusEmail,
password: directusPassword,
})
} else if (directusStaticToken) {
await directus.auth.static(directusStaticToken)
}
return directus
}
When playing cat and mouse game with some console.log(/* ... */)
it appeared that the error originated from both:
await directus.auth.login({ email: directusEmail, password: directusPassword })
and
await directus.auth.static(directusStaticToken)
I double checked, the environment variables exist (and are the right credentials).
It's been 48 hours I've been trying to deploy that without success. I run out of idea.
Has someone ever deployed some frontend fetching Directus data SSR on either of these providers ?