Skip to content

Commit 3dd7273

Browse files
committed
fix: proper CORS_ORIGIN for astro
1 parent 44d7cf4 commit 3dd7273

File tree

3 files changed

+11
-4
lines changed

3 files changed

+11
-4
lines changed

apps/cli/src/helpers/core/env-setup.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,12 +283,16 @@ export async function setupEnvironmentVariables(config: ProjectConfig) {
283283
if (!(await fs.pathExists(serverDir))) {
284284
return;
285285
}
286+
286287
const envPath = path.join(serverDir, ".env");
287288

288289
let corsOrigin = "http://localhost:3001";
289290
if (hasReactRouter || hasSvelte) {
290291
corsOrigin = "http://localhost:5173";
291292
}
293+
if (hasAstro) {
294+
corsOrigin = "http://localhost:4321";
295+
}
292296

293297
let databaseUrl: string | null = null;
294298

apps/cli/templates/api/orpc/web/astro/src/components/orpc-status.tsx.hbs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
import { orpc } from '../lib/orpc';
1+
import { orpc, queryClient } from '../lib/orpc';
22
import { useQuery } from '@tanstack/react-query';
33
import { QueryClientProvider } from '@tanstack/react-query';
4-
import { queryClient } from '../shared/query';
54

65
function ApiStatus() {
76
const healthCheck = useQuery(orpc.healthCheck.queryOptions());

apps/cli/templates/api/orpc/web/astro/src/lib/orpc.ts.hbs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,20 @@ export const queryClient = new QueryClient({
1414
});
1515

1616
export const link = new RPCLink({
17-
url: `${import.meta.env.PUBLIC_SERVER_URL}/rpc`,
17+
url: `${import.meta.env.VITE_SERVER_URL}/rpc`,
1818
plugins: [
19-
// for request batching optimization
2019
new BatchLinkPlugin({
2120
groups: [{
2221
condition: () => true,
2322
context: {},
2423
}],
2524
}),
2625
],
26+
interceptors: [
27+
onError((error) => {
28+
console.error(error)
29+
})
30+
],
2731
});
2832

2933
export const client: AppRouterClient = createORPCClient(link);

0 commit comments

Comments
 (0)