Skip to content

Commit

Permalink
Use env values in configs
Browse files Browse the repository at this point in the history
  • Loading branch information
lorcan-codes committed Oct 26, 2023
1 parent d1e805c commit cfda1e3
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 4 deletions.
1 change: 1 addition & 0 deletions .github/workflows/netlify-cms.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ jobs:
VITE_GIT_BRANCH_NAME: ${{ github.ref_name }}
VITE_API_BASE_URL: https://${{ env.GITHUB_REF_SLUG_URL }}.starknet-website.pages.dev/api
VITE_DATA_URL: https://${{ env.GITHUB_REF_SLUG_URL }}.starknet-website.pages.dev/data
VITE_BACKEND_AUTH_URL: https://auth.clivado.com

- name: Deploy Netlify CMS
uses: cloudflare/pages-action@1
Expand Down
8 changes: 6 additions & 2 deletions workspaces/netlify-cms-auth/src/callback.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export async function callback(
postMessageHTML({
status: "success",
data: { token, provider },
env,
}),
{
headers: {
Expand All @@ -37,6 +38,7 @@ export async function callback(
postMessageHTML({
status: "error",
data: e,
env,
}),
{
headers: {
Expand All @@ -50,9 +52,10 @@ export async function callback(
interface PostMessageHTMLArgs {
status: "success" | "error";
data: any;
env: Env;
}

function postMessageHTML({ status, data }: PostMessageHTMLArgs) {
function postMessageHTML({ status, data, env }: PostMessageHTMLArgs) {
return `
<!DOCTYPE html>
<html>
Expand All @@ -62,7 +65,8 @@ function postMessageHTML({ status, data }: PostMessageHTMLArgs) {
const allowedOrigin = (
message.origin === 'http://localhost:1234' ||
message.origin === 'http://127.0.0.1:1234' ||
/^https:\\/\\/[-_\\w]+\\.starknet-netlify-cms\\.pages\\.dev$/.test(message.origin)
/^https:\\/\\/[-_\\w]+\\.starknet-netlify-cms\\.pages\\.dev$/.test(message.origin) ||
message.origin === '${env.CMS_URL}'
);
if (!allowedOrigin) return;
Expand Down
5 changes: 3 additions & 2 deletions workspaces/netlify-cms-auth/src/env.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export interface Env {
OAUTH_GITHUB_CLIENT_ID: string
OAUTH_GITHUB_CLIENT_SECRET: string
OAUTH_GITHUB_CLIENT_ID: string;
OAUTH_GITHUB_CLIENT_SECRET: string;
CMS_URL: string;
}
2 changes: 2 additions & 0 deletions workspaces/netlify-cms/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,8 @@ export default function App() {
backend: {
...CMSConfig.backend,
branch,
base_url:
import.meta.env.VITE_BACKEND_AUTH_URL || CMSConfig.backend.base_url,
},
},
});
Expand Down

0 comments on commit cfda1e3

Please sign in to comment.