Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
3 changes: 3 additions & 0 deletions e2e/fixtures/ssr-basic/private/config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export default {
content: 'hello world',
};
5 changes: 5 additions & 0 deletions e2e/fixtures/ssr-basic/src/components/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { AIProvider } from '../ai/index.js';
import { AIClient } from './AIClient.js';
import { TestEnvServer } from './test-env/server.js';
import { TestEnvClient } from './test-env/client.js';
import config from '../../private/config.js';

const DelayedBackground = async () => {
await new Promise((resolve) => setTimeout(resolve, 2000));
Expand Down Expand Up @@ -48,6 +49,10 @@ const App = ({ name }: { name: string }) => {
<TestEnvClient />
</div>
</section>
<section>
<h2>Private Config</h2>
<div data-testid="private-content">{config.content}</div>
</section>
</div>
</body>
</html>
Expand Down
7 changes: 7 additions & 0 deletions e2e/ssr-basic.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,4 +112,11 @@ test.describe(`ssr-basic`, () => {
),
);
});

test('private directory access', async ({ page }) => {
await page.goto(`http://localhost:${port}/`);

const privateContent = page.getByTestId('private-content');
await expect(privateContent).toHaveText('hello world');
});
});
5 changes: 4 additions & 1 deletion packages/waku/src/lib/plugins/vite-plugin-rsc-private.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,11 @@ export function rscPrivatePlugin({
privatePath = joinPath(config.root, privateDir);
},
load(id) {
if (this.environment.name === 'rsc') {
return;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't work anyways. So, I think we should remove it to avoid confusion.

if (id.startsWith(privatePath)) {
throw new Error('Private file access is not allowed');
throw new Error('Load private directory in client side is not allowed');
}
},
handleHotUpdate({ file }) {
Expand Down
7 changes: 6 additions & 1 deletion packages/waku/src/vite-rsc/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -538,8 +538,13 @@ if (import.meta.hot) {
{
name: 'rsc:private-dir',
load(id) {
if (this.environment.name === 'rsc') {
return;
}
if (id.startsWith(privatePath)) {
throw new Error('Private file access is not allowed');
throw new Error(
'Load private directory in client side is not allowed',
);
}
},
hotUpdate(ctx) {
Expand Down
Loading