Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion app/src/components/IframeContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export default function IframeContent({
// Derive allowed origin from iframe URL for postMessage validation
const iframeOrigin = useMemo(() => {
try {
return new URL(url).origin;
return new URL(url, window.location.origin).origin;
} catch {
return '';
}
Expand Down
4 changes: 2 additions & 2 deletions app/src/data/apps/appTransformers.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ describe('appTransformers', () => {

test('all apps have valid source URLs', () => {
apps.forEach((app) => {
// Allow external URLs (https://) or local paths (/assets/)
expect(app.source).toMatch(/^(https?:\/\/|\/assets\/)/);
// Allow external URLs, asset files, or same-origin app proxy paths.
expect(app.source).toMatch(/^(https?:\/\/|\/assets\/|\/[a-z]{2}\/)/);
});
});

Expand Down
13 changes: 13 additions & 0 deletions app/src/data/apps/apps.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,19 @@
"date": "2026-03-06 12:00:00",
"authors": ["max-ghenis", "pavel-makarchuk"]
},
{
"type": "iframe",
"slug": "california-wealth-tax",
"title": "California wealth tax fiscal impact calculator",
"description": "Estimate how California's proposed billionaire wealth tax changes revenue once avoidance, migration, return flows, and income-tax offsets are taken into account",
"source": "/us/california-wealth-tax/embed",
"tags": ["us", "us-ca", "policy", "interactives", "tax"],
"countryId": "us",
"displayWithResearch": true,
"image": "california-wealth-tax-calculator.png",
"date": "2026-03-25 12:00:00",
"authors": ["max-ghenis"]
},
{
"type": "iframe",
"slug": "uk-land-value-tax",
Expand Down
43 changes: 43 additions & 0 deletions app/src/tests/unit/components/IframeContent.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import { render } from '@testing-library/react';
import { MemoryRouter, Route, Routes } from 'react-router-dom';
import { afterEach, describe, expect, test, vi } from 'vitest';
import IframeContent from '@/components/IframeContent';

describe('IframeContent', () => {
afterEach(() => {
vi.restoreAllMocks();
});

test('accepts same-origin relative iframe URLs for hash sync messages', () => {
const replaceStateSpy = vi.spyOn(window.history, 'replaceState');

render(
<MemoryRouter initialEntries={['/us/california-wealth-tax']}>
<Routes>
<Route
path="/:countryId/:slug"
element={
<IframeContent url="/us/california-wealth-tax/embed" title="California wealth tax" />
}
/>
</Routes>
</MemoryRouter>
);

window.dispatchEvent(
new MessageEvent('message', {
origin: window.location.origin,
data: {
type: 'hashchange',
hash: '/scenario/rauh',
},
})
);

expect(replaceStateSpy).toHaveBeenCalledWith(
null,
'',
'/us/california-wealth-tax/scenario/rauh'
);
});
});
7 changes: 7 additions & 0 deletions app/vite.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,13 @@ export default defineConfig({
// Use discovered ports in dev, defaults otherwise
port: appMode === 'calculator' ? (calculatorPort ?? 3001) : (websitePort ?? 3000),
strictPort: true,
proxy: {
'/us/california-wealth-tax/embed': {
target: 'https://california-wealth-tax.vercel.app',
changeOrigin: true,
secure: true,
},
},
},
define: viteDefines,
// Use separate cache directories for website and calculator to avoid conflicts
Expand Down
8 changes: 8 additions & 0 deletions vercel.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,14 @@
"source": "/us/keep-your-pay-act/:path*",
"destination": "https://keep-your-pay-act.vercel.app/us/keep-your-pay-act/:path*"
},
{
"source": "/us/california-wealth-tax/embed",
"destination": "https://california-wealth-tax.vercel.app/us/california-wealth-tax/embed"
},
{
"source": "/us/california-wealth-tax/embed/:path*",
"destination": "https://california-wealth-tax.vercel.app/us/california-wealth-tax/embed/:path*"
},
{
"source": "/us/taxsim",
"destination": "https://policyengine-taxsim-policy-engine.vercel.app/us/taxsim"
Expand Down
Loading