Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug(v1): Admin UI is no longer launching on v1.20.11 #11237

Closed
adevinwild opened this issue Jan 31, 2025 · 2 comments
Closed

Bug(v1): Admin UI is no longer launching on v1.20.11 #11237

adevinwild opened this issue Jan 31, 2025 · 2 comments

Comments

@adevinwild
Copy link
Contributor

adevinwild commented Jan 31, 2025

Bug report

The Admin UI is no longer launched on 1.20.11

Describe the bug

The Admin UI is no longer launched on [v1.20.11], this is because this bug I've introduced, sorry 🙌🏼 was missing another fix on the "loadConfig" function

System information

Medusa version (including plugins): v1.20.11

Steps to reproduce the behavior

  1. Use v1.20.11
  2. Try to launch the app server with the @medusajs/admin plugin enabled
  3. Nothing happens

Expected behavior

We should allow a fully configurable serve

Code snippets

I've found a solution, which would explain the logic expressed in the documentation

Instead of doing this :

// packages/admin/src/utils/load-config.ts

// ... for reading purpose

  if (isDev) {
    config = {
      ...config,
      serve: false, // ℹ️ This is problematic
      path: "/",
      backend: "http://localhost:9000",
    }
  }

We should do this :

// packages/admin/src/utils/load-config.ts

// ... for reading purpose

  if (isDev) {
    config = {
      ...config,
      // ✅ We remove the `serve` set to `false` on development mode
      path: "/",
      backend: "http://localhost:9000",
    }
  }

The same goes with the logic a few lines below that one.

// packages/admin/src/utils/load-config.ts

// ...

  if (typeof plugin !== "string") {
    const options = (plugin as { options: PluginOptions }).options ?? {}

    config = {
      serve: isDev ? false : options.serve ?? config.serve, // ℹ️ We also force to `false` here
      // ...

But this should be better :

// packages/admin/src/utils/load-config.ts

// ...

  if (typeof plugin !== "string") {
    const options = (plugin as { options: PluginOptions }).options ?? {}

    config = {
      serve: options.serve ?? config.serve, // ✅ Fully configurable `serve` option
      // ...

Additional context

I've already implemented the solution on a PR that you can find "here"

kodiakhq bot pushed a commit that referenced this issue Feb 7, 2025
#11238)

## Related to #11237

## Solution that PR introduce
- `serve` is always `true` allowing to always start the Admin UI with the new logic in the `develop.js` command file in `@medusajs/medusa`
- `loadConfig` in the `@medusajs/admin` is no longer overriding the `serve` function to false, allowing to fix the current bug we have in v1.20.11 where the Admin UI cannot be launched at all

## Quick preview of the new behavior on a project
In this preview, I try with the different values and how it behaves with the fix.
- No `serve` option -> Default to `true`; Trigger the admin develop
- `serve` set to `false` -> Ignore the admin develop command
- `serve` set to `true` -> Trigger the admin develop

https://github.com/user-attachments/assets/33fdb428-b3ae-466a-9095-b7f8ba0dd822



Co-authored-by: Kasper Fabricius Kristensen <[email protected]>
@kasperkristensen
Copy link
Contributor

Hi @adevinwild, we have released a new version of @medusajs/admin with your fix - 7.1.18.

@adevinwild
Copy link
Contributor Author

Thanks! I'll warn the community members that had issues lately 🙌🏼

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants