Skip to content

Commit

Permalink
Validate CDN URLs
Browse files Browse the repository at this point in the history
  • Loading branch information
Alokih committed Nov 7, 2024
1 parent 5966af0 commit 7a897b4
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/Integrations/Plausible.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,12 @@ export default function Plausible() {
});

useEffect(() => {
if (!careConfig.plausible.domain || !careConfig.plausible.server) {
const missingConfig = [];
if (!careConfig.plausible.domain) missingConfig.push("domain");
if (!careConfig.plausible.server) missingConfig.push("server");
if (missingConfig.length > 0) {
console.error(
"Plausible is not configured correctly. Please check your environment variables.",
`Plausible analytics disabled. Missing configuration: ${missingConfig.join(", ")}`,
);
return;
}
Expand Down
6 changes: 6 additions & 0 deletions vite.config.mts
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,12 @@ export default defineConfig(({ mode }) => {

REACT_PLAUSIBLE_SITE_DOMAIN: z.string().url().optional(),
REACT_PLAUSIBLE_SERVER_URL: z.string().url().optional(),
REACT_CDN_URLS: z
.string()
.optional()
.transform((val) => val?.split(" "))
.pipe(z.array(z.string().url()).optional())
.describe("Optional: Space-separated list of CDN URLs"),
},
}),
viteStaticCopy({
Expand Down

0 comments on commit 7a897b4

Please sign in to comment.