Closed OriGummy closed 3 weeks ago
Hello do you have a repo I can look at?
Idk what happened, but today I am only getting error 500s. Looking at the logs I see it is because the environment variables are missing. for example this passed build but fails runtime:
export const supabase = createClient( import.meta.env.SUPABASE_URL, import.meta.env.SUPABASE_ANON_KEY, );
Is this desired behaviour that they only be used at build time? If not - I'd be happy to implement this myself and commit. Some initial guidance will be helpful.
Nvm! found this handy script:
version: 1
frontend:
phases:
preBuild:
commands:
- npm ci
build:
commands:
- env >> .env
- npm run build
- mv node_modules ./.amplify-hosting/compute/default
- mv .env ./.amplify-hosting/compute/default/.env
artifacts:
baseDirectory: .amplify-hosting
files:
- '**/*'
cache:
paths:
- node_modules/**/*
At https://www.launchfa.st/blog/deploy-astro-aws-amplify, which fixed my problem.
consider uploading to the wiki.
Again thanks for the lib and sorry for troubling you with something I could have fixed myself.
No worries - actually that script is in the readme but not in the docs which I forgot to update sorry - I've updated that now.
Hello and thanks a bunch for making this adapter.
I am having trouble making it work. I follwed all instructions as per the wiki. But I am only getting 404s on every url.
Tech stack:
astro.config.mjs
amplify.yml (in amplify website ui, not in my git)
Downloading the deployment artifacts gives the expected result:
Builds are going on just fine, no problem I see in the logs. Can locally run
npm run dev
just fine, can run with a nodejs adapter on my self hosted server.What could be the cause of this?
Appendix - build logs:
`0
2024-06-20T21:03:49.451Z [INFO]: # Cloning repository: git@github.com:OriGummy/Academease.git
1
2024-06-20T21:03:50.968Z [INFO]:
2
2024-06-20T21:03:50.969Z [INFO]: Cloning into 'Academease'...
3
2024-06-20T21:03:50.969Z [INFO]: # Switching to commit: 1683d091c757e7408e1f17fc274dd8e31f1e6064
4
2024-06-20T21:03:51.017Z [INFO]: Note: switching to '1683d091c757e7408e1f17fc274dd8e31f1e6064'.
5
You are in 'detached HEAD' state. You can look around, make experimental
6
changes and commit them, and you can discard any commits you make in this
7
state without impacting any branches by switching back to a branch.
8
If you want to create a new branch to retain commits you create, you may
9
do so (now or later) by using -c with the switch command. Example:
10
git switch -c
11
Or undo this operation with:
12
git switch -
13
Turn off this advice by setting config variable advice.detachedHead to false
14
HEAD is now at 1683d09 fix
15
2024-06-20T21:03:51.116Z [INFO]: Successfully cleaned up Git credentials
16
2024-06-20T21:03:51.117Z [INFO]: # Checking for Git submodules at: /codebuild/output/src2988892587/src/Academease/.gitmodules
17
2024-06-20T21:03:51.123Z [INFO]: # Retrieving environment cache...
18
2024-06-20T21:03:51.219Z [INFO]: # Retrieved environment cache
19
2024-06-20T21:03:51.219Z [INFO]: ---- Setting Up SSM Secrets ----
20
2024-06-20T21:03:51.219Z [INFO]: SSM params {"Path":"/amplify/d3f2zbboiiam9y/master/","WithDecryption":true}
21
2024-06-20T21:03:52.235Z [INFO]: No live updates for this build run
22
2024-06-20T21:03:52.239Z [INFO]: # Retrieving cache...
23
2024-06-20T21:03:52.306Z [INFO]: # Extracting cache...
24
2024-06-20T21:03:52.308Z [INFO]: # Extraction completed
25
2024-06-20T21:03:52.308Z [INFO]: # Retrieved cache
26
2024-06-20T21:03:57.901Z [INFO]: ## Starting Backend Build
27
Checking for associated backend environment...
28
No backend environment association found, continuing...
29
Completed Backend Build
30
2024-06-20T21:03:57.907Z [INFO]: {"backendDuration": 0}
31
Starting Frontend Build
32
Starting phase: preBuild
33 Tech stack:
Executing command: npm ci
34
2024-06-20T21:04:24.992Z [WARNING]: npm WARN deprecated inflight@1.0.6: This module is not supported, and leaks memory. Do not use it. Check out lru-cache if you want a good and tested way to coalesce async requests by a key value, which is much more comprehensive and powerful.
35
2024-06-20T21:04:25.427Z [WARNING]: npm WARN deprecated glob@7.2.3: Glob versions prior to v9 are no longer supported
36
2024-06-20T21:04:25.430Z [WARNING]: npm WARN
37
2024-06-20T21:04:25.430Z [WARNING]: deprecated glob@7.2.3: Glob versions prior to v9 are no longer supported
38
2024-06-20T21:04:25.440Z [WARNING]: npm WARN
39
2024-06-20T21:04:25.440Z [WARNING]: deprecated glob@7.2.3: Glob versions prior to v9 are no longer supported
40
2024-06-20T21:04:29.604Z [INFO]: added 707 packages, and audited 708 packages in 17s
41
2024-06-20T21:04:29.610Z [INFO]: 219 packages are looking for funding
42
run
npm fund
for details43
2 high severity vulnerabilities
44
To address all issues, run:
45
npm audit fix
46
Run
npm audit
for details.47
2024-06-20T21:04:29.625Z [INFO]: # Completed phase: preBuild
48
Starting phase: build
49
Executing command: npm run build
50
2024-06-20T21:04:29.963Z [INFO]: > academease@0.0.1 build
51
52
2024-06-20T21:04:33.354Z [INFO]: 21:04:33 [vite] Forced re-optimization of dependencies
53
2024-06-20T21:04:33.377Z [INFO]: 21:04:33 Types generated 50ms
54
2024-06-20T21:04:33.383Z [INFO]: 21:04:33 [check] Getting diagnostics for Astro files in /codebuild/output/src2988892587/src/Academease...
55
2024-06-20T21:04:36.475Z [INFO]: [96mastro.config.mjs[0m:[93m3[0m:[93m1[0m - [93mwarning[0m[90m ts(6133): [0m'node' is declared but its value is never read.
56
[7m3[0m import node from "@astrojs/node";
57
[7m [0m [93m
~~~~~~~~~[0m58
2024-06-20T21:04:36.761Z [INFO]: [96msrc/components/Nav.astro[0m:[93m44[0m:[93m9[0m - [93mwarning[0m[90m astro(4000): [0mThis script will be treated as if it has the
is:inline
directive because it contains an attribute. Therefore, features that require processing (e.g. using TypeScript or npm packages in the script) are unavailable.59
See docs for more details: https://docs.astro.build/en/guides/client-side-scripts/#script-processing.
60
Add the
is:inline
directive explicitly to silence this hint.61
[7m44[0m
62
[7m [0m [93m
~~~~[0m63
2024-06-20T21:04:36.835Z [INFO]: [96msrc/components/Regin.astro[0m:[93m6[0m:[93m11[0m - [93mwarning[0m[90m ts(6133): [0m'error' is declared but its value is never read.
64
[7m6[0m let { error, isLoggedIn, user } = await ensureAuth(Astro.cookies);
65
[7m [0m [93m
~[0m66
2024-06-20T21:04:36.867Z [INFO]: [96msrc/components/Syllabus.astro[0m:[93m12[0m:[93m37[0m - [93mwarning[0m[90m ts(6133): [0m'i' is declared but its value is never read.
67
[7m12[0m {course.sections.map((section: any, i: number) => (
68
[7m [0m [93m ~[0m
69
[96msrc/components/Syllabus.astro[0m:[93m3[0m:[93m1[0m - [93mwarning[0m[90m ts(6192): [0mAll imports in import declaration are unused.
70
[7m3[0m import { getCourseByName, setCourseContents, parseCourseSheet } from '../lib/courses';
71
[7m [0m [93m
~~~~~~~~~~~~~~~~~~[0m72
[96msrc/components/Syllabus.astro[0m:[93m2[0m:[93m1[0m - [93mwarning[0m[90m ts(6133): [0m'string' is declared but its value is never read.
73
[7m2[0m import { string } from 'astro/zod';
74
[7m [0m [93m
~~~~~~~[0m75
2024-06-20T21:04:36.927Z [INFO]: [96msrc/layouts/Layout.astro[0m:[93m6[0m:[93m1[0m - [93mwarning[0m[90m ts(6133): [0m'Regin' is declared but its value is never read.
76
[7m6[0m import Regin from '../components/Regin.astro';
77
[7m [0m [93m
~~~~~~~~~~[0m78
2024-06-20T21:04:36.950Z [INFO]: [96msrc/lib/auth.ts[0m:[93m5[0m:[93m1[0m - [93mwarning[0m[90m ts(6133): [0m'boolean' is declared but its value is never read.
79
[7m5[0m import { boolean } from "astro/zod";
80
[7m [0m [93m
~~~~~~~~[0m81
[96msrc/lib/auth.ts[0m:[93m4[0m:[93m1[0m - [93mwarning[0m[90m ts(6133): [0m'Auth' is declared but its value is never read.
82
[7m4[0m import type { Auth } from "./types";
83
[7m [0m [93m
~~~~~~~~[0m84
[96msrc/lib/auth.ts[0m:[93m3[0m:[93m29[0m - [93mwarning[0m[90m ts(6196): [0m'Session' is declared but never used.
85
[7m3[0m import type { AuthResponse, Session, User } from "@supabase/supabase-js";
86
[7m [0m [93m
~~~[0m87
[96msrc/lib/auth.ts[0m:[93m3[0m:[93m15[0m - [93mwarning[0m[90m ts(6196): [0m'AuthResponse' is declared but never used.
88
[7m3[0m import type { AuthResponse, Session, User } from "@supabase/supabase-js";
89
[7m [0m [93m
~~~~[0m90
2024-06-20T21:04:37.075Z [INFO]: [96msrc/lib/vdocipher.ts[0m:[93m1[0m:[93m60[0m - [93mwarning[0m[90m ts(6133): [0m'watermark' is declared but its value is never read.
91
[7m1[0m export async function getVideoCredentials(videoId: string, watermark: string): Promise<{error: boolean, otp: string, playbackInfo: string}> {
92
[7m [0m [93m
~~~~~[0m93
2024-06-20T21:04:37.156Z [INFO]: [96msrc/pages/dashboard.astro[0m:[93m7[0m:[93m18[0m - [93mwarning[0m[90m ts(6133): [0m'redirect' is declared but its value is never read.
94
[7m7[0m const { cookies, redirect } = Astro;
95
[7m [0m [93m
~~~~[0m96
2024-06-20T21:04:37.223Z [INFO]: [96msrc/pages/signin.astro[0m:[93m11[0m:[93m7[0m - [93mwarning[0m[90m ts(6133): [0m'contUrl' is declared but its value is never read.
97
[7m11[0m const contUrl = cont ? decodeURIComponent(cont) : '/courses/tapi2-htn'
98
[7m [0m [93m
~~~[0m99
[96msrc/pages/signin.astro[0m:[93m7[0m:[93m27[0m - [93mwarning[0m[90m ts(6133): [0m'redirect' is declared but its value is never read.
100
[7m7[0m const { cookies, request, redirect } = Astro;
101
[7m [0m [93m
~~~~[0m102
2024-06-20T21:04:37.257Z [INFO]: [96msrc/pages/watch.astro[0m:[93m19[0m:[93m27[0m - [93mwarning[0m[90m ts(6133): [0m'error' is declared but its value is never read.
103
[7m19[0m const { user, isLoggedIn, error } = await ensureAuth(cookies);
104
[7m [0m [93m
~[0m105
[96msrc/pages/watch.astro[0m:[93m9[0m:[93m27[0m - [93mwarning[0m[90m ts(6133): [0m'redirect' is declared but its value is never read.
106
[7m9[0m const { request, cookies, redirect } = Astro;
107
[7m [0m [93m
~~~~[0m108
2024-06-20T21:04:37.291Z [INFO]: [96msrc/pages/api/auth/confirm.ts[0m:[93m18[0m:[93m3[0m - [93mwarning[0m[90m ts(80007): [0m'await' has no effect on the type of this expression.
109
[7m18[0m await supabase.auth.setSession
110
[7m [0m [93m
~~~~~~[0m111
[96msrc/pages/api/auth/confirm.ts[0m:[93m1[0m:[93m1[0m - [93mwarning[0m[90m ts(6133): [0m'createServerClient' is declared but its value is never read.
112
[7m1[0m import { createServerClient } from '@supabase/ssr'
113
[7m [0m [93m
~~~~~~~~~~[0m114
2024-06-20T21:04:37.453Z [INFO]: [96msrc/pages/course/[courseName].astro[0m:[93m9[0m:[93m10[0m - [93mwarning[0m[90m ts(6133): [0m'formatPrice' is declared but its value is never read.
115
[7m9[0m import { formatPrice, getCourseByName, getOrFetchCourses } from '../../lib/courses';
116
[7m [0m [93m
~~~[0m117
[96msrc/pages/course/[courseName].astro[0m:[93m6[0m:[93m1[0m - [93mwarning[0m[90m ts(6133): [0m'PublicVideo' is declared but its value is never read.
118
[7m6[0m import PublicVideo from "../../components/PublicVideo.svelte";
119
[7m [0m [93m
~~~~~~~~~~~~~~[0m120
[96msrc/pages/course/[courseName].astro[0m:[93m2[0m:[93m1[0m - [93mwarning[0m[90m ts(6133): [0m'LoginModal' is declared but its value is never read.
121
[7m2[0m import LoginModal from "../../components/LoginModal.svelte";
122
[7m [0m [93m
~~~~~~~~~~~~[0m123
2024-06-20T21:04:37.465Z [INFO]: Result (40 files):
124
125
126
127
2024-06-20T21:04:39.060Z [INFO]: 21:04:39 [build] output: "server"
128
2024-06-20T21:04:39.060Z [INFO]: 21:04:39 [build] directory: /codebuild/output/src2988892587/src/Academease/dist/
129
21:04:39 [build] adapter: astro-aws-amplify
130
21:04:39 [build] Collecting build info...
131
2024-06-20T21:04:39.061Z [INFO]: 21:04:39 [build] β Completed in 100ms.
132
2024-06-20T21:04:39.062Z [INFO]: 21:04:39 [build] Building server entrypoints...
133
2024-06-20T21:04:40.097Z [INFO]:
134
2024-06-20T21:04:40.101Z [INFO]: πΌ daisyUI 4.10.5
135
2024-06-20T21:04:40.286Z [INFO]: ββ βοΈ 1 theme added https://daisyui.com/docs/themes
136
β°β β€οΈ Support daisyUI project: https://opencollective.com/daisyui
137
2024-06-20T21:04:40.377Z [INFO]: 21:04:40 [WARN] [router] getStaticPaths() ignored in dynamic page /src/pages/course/[courseName].astro. Add
export const prerender = true;
to prerender the page as static HTML during the build process.138
2024-06-20T21:04:40.490Z [INFO]:
139
2024-06-20T21:04:40.490Z [INFO]: πΌ daisyUI 4.10.5
140
2024-06-20T21:04:40.614Z [INFO]: ββ βοΈ 1 theme added https://daisyui.com/docs/themes
141
2024-06-20T21:04:40.614Z [INFO]: β°β β€οΈ Support daisyUI project: https://opencollective.com/daisyui
142
2024-06-20T21:04:40.986Z [INFO]:
143
2024-06-20T21:04:40.986Z [INFO]: πΌ daisyUI 4.10.5
144
2024-06-20T21:04:41.083Z [INFO]: ββ βοΈ 1 theme added https://daisyui.com/docs/themes
145
2024-06-20T21:04:41.083Z [INFO]: β°β β Star daisyUI on GitHub https://github.com/saadeghi/daisyui
146
2024-06-20T21:04:41.321Z [WARNING]: src/lib/auth.ts (5:9): "boolean" is not exported by "node_modules/astro/zod.mjs", imported by "src/lib/auth.ts".
147
2024-06-20T21:04:41.586Z [WARNING]: "createServerClient" is imported from external module "@supabase/ssr" but never used in "src/pages/api/auth/confirm.ts".
148
2024-06-20T21:04:41.710Z [INFO]: 21:04:41 [vite] β built in 2.62s
149
2024-06-20T21:04:41.710Z [INFO]: 21:04:41 [build] β Completed in 2.65s.
150
2024-06-20T21:04:41.711Z [INFO]: building client (vite)
151
2024-06-20T21:04:41.721Z [INFO]: 21:04:41 [vite] transforming...
152
2024-06-20T21:04:42.854Z [INFO]: 21:04:42 [vite] β 86 modules transformed.
153
2024-06-20T21:04:42.914Z [INFO]: 21:04:42 [vite] rendering chunks...
154
2024-06-20T21:04:42.949Z [INFO]: 21:04:42 [vite] computing gzip size...
155
2024-06-20T21:04:42.953Z [INFO]: 21:04:42 [vite] .amplify-hosting/static/_astro/CourseSearch.CK2nybs4.css 12.24 kB β gzip: 2.60 kB
156
2024-06-20T21:04:42.954Z [INFO]: 21:04:42 [vite] .amplify-hosting/static/_astro/ModalPlayer.CKVDkQZy.js 0.11 kB β gzip: 0.12 kB
157
21:04:42 [vite] .amplify-hosting/static/_astro/Flip.B4b0OeDg.js 0.27 kB β gzip: 0.22 kB
158
21:04:42 [vite] .amplify-hosting/static/_astro/index.Mc1atRao.js 0.60 kB β gzip: 0.34 kB
159
21:04:42 [vite] .amplify-hosting/static/_astro/client.Cx1FBVJX.js 0.61 kB β gzip: 0.42 kB
160
21:04:42 [vite] .amplify-hosting/static/_astro/hoisted.D8GstF-U.js 1.15 kB β gzip: 0.55 kB
161
21:04:42 [vite] .amplify-hosting/static/_astro/LoginModal.BgAZOBtJ.js 2.04 kB β gzip: 1.14 kB
162
21:04:42 [vite] .amplify-hosting/static/_astro/Register.DltBnCMC.js 2.12 kB β gzip: 1.28 kB
163
21:04:42 [vite] .amplify-hosting/static/_astro/BinaryContainer.bk8hxhFc.js 2.37 kB β gzip: 1.18 kB
164
21:04:42 [vite] .amplify-hosting/static/_astro/AlertableInput.CyRiiSMc.js 2.85 kB β gzip: 1.22 kB
165
2024-06-20T21:04:42.954Z [INFO]: 21:04:42 [vite] .amplify-hosting/static/_astro/Login.BbCkhsML.js 4.15 kB β gzip: 2.28 kB
166
2024-06-20T21:04:42.955Z [INFO]: 21:04:42 [vite] .amplify-hosting/static/_astro/ModalPlayer.CUlXSFUu.js 4.72 kB β gzip: 2.19 kB
167
21:04:42 [vite] .amplify-hosting/static/_astro/index.CpZHJYDq.js 11.85 kB β gzip: 4.89 kB
168
21:04:42 [vite] .amplify-hosting/static/_astro/hoisted.B8e_A8KY.js 14.12 kB β gzip: 4.87 kB
169
21:04:42 [vite] .amplify-hosting/static/_astro/CourseSearch.BTDBPqn-.js 50.50 kB β gzip: 18.29 kB
170
21:04:42 [vite] β built in 1.24s
171
2024-06-20T21:04:42.968Z [INFO]: 21:04:42
172
finalizing server assets
173
2024-06-20T21:04:42.969Z [INFO]: 21:04:42 [build] Rearranging server assets...
174
2024-06-20T21:04:42.970Z [INFO]: 21:04:42 [build] Server built in 4.01s
175
2024-06-20T21:04:42.970Z [INFO]: 21:04:42 [build] Complete!
176
2024-06-20T21:04:42.991Z [INFO]: # Executing command: mv node_modules ./.amplify-hosting/compute/default
177
2024-06-20T21:04:42.993Z [INFO]: # Completed phase: build
178
Completed Frontend Build
179
2024-06-20T21:04:43.001Z [INFO]: ## Build completed successfully
180
2024-06-20T21:04:43.002Z [INFO]: # Starting caching...
181
2024-06-20T21:04:43.010Z [INFO]: # Creating cache artifact...
182
2024-06-20T21:04:43.013Z [INFO]: # Created cache artifact
183
2024-06-20T21:04:43.013Z [INFO]: # Uploading cache artifact...
184
2024-06-20T21:04:43.113Z [INFO]: # Uploaded cache artifact
185
2024-06-20T21:04:43.113Z [INFO]: # Caching completed
186
2024-06-20T21:05:06.403Z [INFO]: # Starting environment caching...
187
2024-06-20T21:05:06.500Z [INFO]: # Uploading environment cache artifact...
188
2024-06-20T21:05:06.604Z [INFO]: # Uploaded environment cache artifact
189
2024-06-20T21:05:06.604Z [INFO]: # Environment caching completed
190
191
`