Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

reproduction case for CORS issue with server functions #24

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion .env.local.example
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
WORKOS_CLIENT_ID=
WORKOS_API_KEY=
WORKOS_REDIRECT_URI=http://localhost:3000/callback
WORKOS_REDIRECT_URI=http://localhost:3000/auth/callback
WORKOS_COOKIE_PASSWORD=

24 changes: 15 additions & 9 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"dependencies": {
"@radix-ui/react-icons": "^1.3.0",
"@radix-ui/themes": "^3.0.1",
"@workos-inc/authkit-nextjs": "0.4.1",
"@workos-inc/authkit-nextjs": "0.5.3",
"next": "14.1.3",
"react": "^18",
"react-dom": "^18"
Expand Down
File renamed without changes.
4 changes: 4 additions & 0 deletions src/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ export default function RootLayout({
<Button asChild variant="soft">
<NextLink href="/account">Account</NextLink>
</Button>

<Button asChild variant="soft">
<NextLink href="/test">Test</NextLink>
</Button>
</Flex>

<SignInButton />
Expand Down
18 changes: 18 additions & 0 deletions src/app/test/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
"use client";
import { useEffect } from "react";
import { getUser } from "@workos-inc/authkit-nextjs";
import { Text, Heading, TextField, Flex, Box } from "@radix-ui/themes";

import { serverFunction } from "../../server-function";

export default function TestPage() {
return (
<>
<p>This is just a test page</p>

<button type="button" onClick={() => serverFunction()}>
Trigger server function
</button>
</>
);
}
9 changes: 7 additions & 2 deletions src/middleware.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import { authkitMiddleware } from "@workos-inc/authkit-nextjs";

export default authkitMiddleware();
export default authkitMiddleware({
middlewareAuth: {
enabled: true,
unauthenticatedPaths: ["/auth/callback"],
},
});

// Match against the pages
export const config = { matcher: ["/", "/account/:path*"] };
// export const config = { matcher: ["/", "/account/:path*"] };
6 changes: 6 additions & 0 deletions src/server-function.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
"use server";

export async function serverFunction() {
"use server";
console.log("a function on the server");
}