-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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]: @actual-app/api does not work when bundled #3384
Comments
Workaround for Next.js: Edit import CopyPlugin from 'copy-webpack-plugin';
import path from 'path';
/** @type {import('next').NextConfig} */
const nextConfig = {
webpack: (config) => {
// Change rootPath for @actual-app/api to find resources
config.module.rules.push({
test: /@actual-app.*\.js$/,
loader: 'string-replace-loader',
options: {
search: 'let rootPath = .*?;',
replace: `let rootPath = "${path.resolve('.next/@actual-app').replaceAll('\\', '\\\\')}"`,
flags: 'g',
},
});
// Copy @actual-app/api resources
config.plugins.push(
new CopyPlugin({
patterns: [
{
from: 'node_modules/@actual-app/api/dist/migrations',
to: '@actual-app/migrations',
},
{
from: 'node_modules/@actual-app/api/dist/default-db.sqlite',
to: '@actual-app/default-db.sqlite',
},
],
}),
);
return config;
},
};
export default nextConfig; |
@rodrigost23 I built a new script with the latest api (6.10.0) and actual version (24.9.0) and I'm seeing a consistent "Database is out of sync with migrations" error. This is both with "old" data and a brand new budget. Could it be related to your issue? If not I'll break this out.
|
Yes, I was having the same error before I used the custom webpack configuration. The problem was that the Actual API was trying to find the The workaround was to set all |
Verified issue does not already exist?
What happened?
I was trying to use the API in a Next.js environment. But it bundles the dependencies into chunks, and when @actual/api uses "__dirname" to find the root path, it ends up in my disk root, thus not able to find the migrations folder.
It does not make sense to find a folder using __dirname as in:
actual/packages/loot-core/src/platform/server/fs/index.electron.ts
Lines 9 to 15 in 61bffa3
There should be a way to set this rootPath manually, maybe instead of setting the data path, as everything would be under the root path, or at least setting the migrations path.
Where are you hosting Actual?
Locally via Yarn
What browsers are you seeing the problem on?
Firefox
Operating System
Windows 11
The text was updated successfully, but these errors were encountered: