Skip to content

Commit

Permalink
wip: add dev/prod env config for worker
Browse files Browse the repository at this point in the history
  • Loading branch information
Battlesquid committed Dec 12, 2024
1 parent 6742c4d commit 5d51775
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 5 deletions.
1 change: 1 addition & 0 deletions packages/app/.env.development
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
PUBLIC_WORKER_URL=https://gh-skyline-dev.battlesquid.workers.dev/
1 change: 1 addition & 0 deletions packages/app/.env.production
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
PUBLIC_WORKER_URL=https://gh-skyline.battlesquid.workers.dev/
4 changes: 1 addition & 3 deletions packages/app/src/api/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const getToken = async (): Promise<string | null> => {
location.search.replace(/\bcode=\w+/, "").replace(/\?$/, "");
history.pushState({}, "", path);

const response = await fetch("https://gh-skyline.battlesquid.workers.dev/", {
const response = await fetch(import.meta.env.PUBLIC_WORKER_URL, {
method: "POST",
mode: "cors",
headers: {
Expand Down Expand Up @@ -46,10 +46,8 @@ export const client = new Client({
return {
addAuthToOperation(operation) {
if (!token) {
console.log("no token found");
return operation;
}
console.log("appending token to header");
return utils.appendHeaders(operation, {
Authorization: `Bearer ${token}`
})
Expand Down
2 changes: 1 addition & 1 deletion packages/app/src/env.d.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
// / <reference types="@rsbuild/core/types" />
/// <reference types="@rsbuild/core/types" />
4 changes: 3 additions & 1 deletion packages/worker/wrangler.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@ name = "gh-skyline"
account_id = "43a4f22039b08a57004057adc36bf4d0"
compatibility_date = "2024-12-10"
workers_dev = true
main = "src/index.ts"
main = "src/index.ts"

[env.dev]

0 comments on commit 5d51775

Please sign in to comment.