Closed iamanle closed 9 months ago
this does not seems to be an issue with the auth plugin no? looks like the issue comes from loading the medusa-config plugins.
I do have the same issue though. It's happening with the auth plugin only.
"medusa-plugin-auth": "^1.10.4",
"@medusajs/medusa": "1.20.2",
I get:
> cross-env ./node_modules/.bin/rimraf dist
> medusa-starter-default@0.0.1 build:admin
> cross-env medusa-admin build
TypeError: Cannot read properties of undefined (reading 'plugins')
at loadConfig (/my-store/node_modules/@medusajs/admin/utils/load-config.js:8:31)
at Command.<anonymous> (/my-store/node_modules/@medusajs/admin/commands/build.js:50:49)
at step (/my-store/node_modules/@medusajs/admin/commands/build.js:33:23)
at Object.next (/my-store/node_modules/@medusajs/admin/commands/build.js:14:53)
at /my-store/node_modules/@medusajs/admin/commands/build.js:8:71
at new Promise (<anonymous>)
at __awaiter (/my-store/node_modules/@medusajs/admin/commands/build.js:4:12)
at Command.build (/my-store/node_modules/@medusajs/admin/commands/build.js:45:12)
at Command.listener [as _actionHandler] (/my-store/node_modules/commander/lib/command.js:482:17)
at /my-store/node_modules/commander/lib/command.js:1283:65
@adrien2p you might want to reopen this IMO.
@adrien2p so I've done a bit of testing. The build fails when you set a value for options.store.callbackUrl
.
The following config crashes:
{
resolve: 'medusa-plugin-auth',
/** @type {import('medusa-plugin-auth').AuthOptions} */
options: [
{
type: 'auth0',
strict: 'all',
identifier: 'auth0',
clientID: process.env.AUTH0_CLIENT_ID,
clientSecret: process.env.AUTH0_CLIENT_SECRET,
auth0Domain: process.env.AUTH0_DOMAIN,
admin: {
callbackUrl: `${ADMIN_URL}/admin/auth/auth0/cb`,
failureRedirect: `${ADMIN_URL}/login`,
successRedirect: `${ADMIN_URL}/`,
},
store: {
callbackUrl: `${BACKEND_URL}/store/auth/auth0/cb`,
failureRedirect: `${STORE_URL}/login`,
successRedirect: `${STORE_URL}/`,
},
},
],
},
while this one doesn't:
{
resolve: 'medusa-plugin-auth',
/** @type {import('medusa-plugin-auth').AuthOptions} */
options: [
{
type: 'auth0',
strict: 'all',
identifier: 'auth0',
clientID: process.env.AUTH0_CLIENT_ID,
clientSecret: process.env.AUTH0_CLIENT_SECRET,
auth0Domain: process.env.AUTH0_DOMAIN,
admin: {
callbackUrl: `${ADMIN_URL}/admin/auth/auth0/cb`,
failureRedirect: `${ADMIN_URL}/login`,
successRedirect: `${ADMIN_URL}/`,
},
store: {
// callbackUrl: `${BACKEND_URL}/store/auth/auth0/cb`,
failureRedirect: `${STORE_URL}/login`,
successRedirect: `${STORE_URL}/`,
},
},
],
},
Alright, so, I added some logging in /my-store/node_modules/@medusajs/admin/utils/load-config.js
and interesting find right there which explains everything:
var configModule = (0, medusa_core_utils_1.getConfigFile)(process.cwd(), "medusa-config").configModule;
console.log('configModule', (0, medusa_core_utils_1.getConfigFile)(process.cwd(), "medusa-config"));
Gives me this log:
> medusa-starter-default@0.0.1 build:admin
> cross-env medusa-admin build
configModule {
configModule: undefined,
configFilePath: '/my-store/medusa-config.js',
error: ReferenceError: BACKEND_URL is not defined
at Object.<anonymous> (/my-store/medusa-config.js:63:29)
I guess:
Env:
Config setup: As usual for firebase
Error: When
yarn build
: