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

Storage path is resolved at build time #3017

Closed
mitto98 opened this issue Jan 22, 2025 · 1 comment
Closed

Storage path is resolved at build time #3017

mitto98 opened this issue Jan 22, 2025 · 1 comment

Comments

@mitto98
Copy link

mitto98 commented Jan 22, 2025

Environment

Latest nitro version, the issue is not related to the environment.

Reproduction

To reproduce this issue you need to have storage configured with an fs or fslite driver, like in the following nitro configuration:

export default defineNitroConfig({
  srcDir: "server",

  storage: {
    test: {
      driver: "fs",
      base: ".data/test",
    }
  },

  compatibilityDate: "2025-01-22",
});

Describe the bug

The createStorage method called in the Nitro build process hardcodes the current build directory path into the build artifacts. This behavior causes issues when the compiled project is moved to a different environment (e.g., when deployed in a container).

storage.mount('test', unstorage_47drivers_47fs({"driver":"fs","base":"/Users/mitto98/projects/<project>/.data/test","ignore":["**/node_modules/**","**/.git/**"]}));

This code block is produced in rollup/plugins/storage.ts and calls the createStorage method defined in core/utils/storage.ts.
Here it will call the unstorage defineDriver for the appropriate driver and set the returned value as first parameter for the mount method.

I think that the createStorage utility from nitro should be called at runtime, and not at build time. In this way the build path will not be set as a prefix for the driver path, instead it will use the current working directory of the project.

This is related to this issue unjs/unstorage#566

Additional context

No response

Logs

@pi0
Copy link
Member

pi0 commented Jan 24, 2025

Thanks for report. This issue is solved by #2977 in nitro however not released yet you can try via nitro nightly release channel.

(if you had issues with nightly still, please ping me)

@pi0 pi0 closed this as completed Jan 24, 2025
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