Skip to content

Commit

Permalink
fix: added access-control-allow-origin header to auth routes (#299)
Browse files Browse the repository at this point in the history
  • Loading branch information
BraydenRoyston authored Dec 17, 2023
1 parent f0a6727 commit 1ea563c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
5 changes: 5 additions & 0 deletions backend/typescript/rest/authRoutes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ const cookieOptions: CookieOptions = {
secure: process.env.NODE_ENV === "production",
};

authRouter.use((req, res, next) => {
res.setHeader('Access-Control-Allow-Origin', '*');

Check failure on line 29 in backend/typescript/rest/authRoutes.ts

View workflow job for this annotation

GitHub Actions / run-lint

Replace `'Access-Control-Allow-Origin',·'*'` with `"Access-Control-Allow-Origin",·"*"`

Check failure on line 29 in backend/typescript/rest/authRoutes.ts

View workflow job for this annotation

GitHub Actions / run-lint

Replace `'Access-Control-Allow-Origin',·'*'` with `"Access-Control-Allow-Origin",·"*"`
next();
});

/* Returns access token and user info in response body and sets refreshToken as an httpOnly cookie */
authRouter.post("/login", loginRequestValidator, async (req, res) => {
try {
Expand Down
3 changes: 1 addition & 2 deletions frontend/src/components/auth/Login.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ const Login = (): React.ReactElement => {
const res: AuthenticatedUser | string = await authAPIClient.loginWithGoogle(
tokenId,
);

console.log(res);
if (isAuthenticatedUserType(res)) {
setLoginStatus("success");
setAuthenticatedUser(res);
Expand Down Expand Up @@ -82,7 +82,6 @@ const Login = (): React.ReactElement => {
<VStack spacing={5} w="300px">
<GoogleLogin
onSuccess={(response: CredentialResponse): void => {
console.log(response);
if (response.credential) {
onGoogleLoginSuccess(response.credential);
} else {
Expand Down

0 comments on commit 1ea563c

Please sign in to comment.