@@ -3,10 +3,13 @@ import * as auth from 'aws-amplify/auth';
3
3
import type { Schema } from './../data/resource.js' ;
4
4
import { Amplify } from 'aws-amplify' ;
5
5
import { generateClient } from 'aws-amplify/api' ;
6
- // @ts -expect-error this file will not exist until sandbox is created
7
- import outputs from '../../amplify_outputs.json' ;
6
+ // @ts -ignore this file will not exist until sandbox is created
7
+ // import outputs from '../../amplify_outputs.json';
8
8
import { SemVer } from 'semver' ;
9
9
import crypto from 'node:crypto' ;
10
+ import path from 'node:path' ;
11
+ import { fileURLToPath } from 'node:url' ;
12
+ import { readFile } from 'node:fs/promises' ;
10
13
11
14
// TODO: this is a work around - in theory this should be fixed
12
15
// it seems like as of amplify v6 , some of the code only runs in the browser ...
@@ -19,6 +22,14 @@ if (process.versions.node) {
19
22
}
20
23
}
21
24
25
+ const filename = fileURLToPath ( import . meta. url ) ;
26
+ const dirname = path . dirname ( filename ) ;
27
+ const outputFile = path . normalize (
28
+ path . join ( dirname , '..' , '..' , 'amplify_outputs.json' ) ,
29
+ ) ;
30
+
31
+ const outputs = JSON . parse ( await readFile ( outputFile , { encoding : 'utf8' } ) ) ;
32
+
22
33
Amplify . configure ( outputs ) ;
23
34
24
35
const dataClient = generateClient < Schema > ( ) ;
0 commit comments