Skip to content

Commit

Permalink
Merge pull request Vo-Huy-Khoa#113 from Vo-Huy-Khoa/feat/khoavh/refuc…
Browse files Browse the repository at this point in the history
…tor-frontend

update allow cors
  • Loading branch information
Vo-Huy-Khoa authored Apr 25, 2023
2 parents b843a43 + fe00c02 commit c5a24f8
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 10 deletions.
2 changes: 1 addition & 1 deletion frontend/.env.development
Original file line number Diff line number Diff line change
@@ -1 +1 @@
REACT_APP_API_URL=http://ec2-43-207-219-177.ap-northeast-1.compute.amazonaws.com:3001/api
REACT_APP_API_URL=http://localhost:3001/api
14 changes: 14 additions & 0 deletions frontend/api/cors.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
export default function cors(req, res, next) {
res.setHeader("Access-Control-Allow-Credentials", "true");
res.setHeader("Access-Control-Allow-Origin", "*");
res.setHeader(
"Access-Control-Allow-Methods",
"GET,OPTIONS,PATCH,DELETE,POST,PUT"
);
res.setHeader(
"Access-Control-Allow-Headers",
"X-CSRF-Token, X-Requested-With, Accept, Accept-Version, Content-Length, Content-MD5, Content-Type, Date, X-Api-Version"
);
next();
}

4 changes: 4 additions & 0 deletions frontend/src/services/instance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ const instanceAxios = axios.create({
headers: {
"Content-Type": "application/json",
"Access-Control-Allow-Origin": "*",
"Access-Control-Allow-Credentials": "true",
"Access-Control-Allow-Methods": "GET,OPTIONS,PATCH,DELETE,POST,PUT",
"Access-Control-Allow-Headers":
"X-CSRF-Token, X-Requested-With, Accept, Accept-Version, Content-Length, Content-MD5, Content-Type, Date, X-Api-Version"
},
});

Expand Down
9 changes: 0 additions & 9 deletions frontend/vercel.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,6 @@
{ "key": "Access-Control-Allow-Methods", "value": "GET,OPTIONS,PATCH,DELETE,POST,PUT" },
{ "key": "Access-Control-Allow-Headers", "value": "X-CSRF-Token, X-Requested-With, Accept, Accept-Version, Content-Length, Content-MD5, Content-Type, Date, X-Api-Version" }
]
},
{
"source": "/auth/sign-in",
"headers": [
{ "key": "Access-Control-Allow-Credentials", "value": "true" },
{ "key": "Access-Control-Allow-Origin", "value": "*" },
{ "key": "Access-Control-Allow-Methods", "value": "GET,OPTIONS,PATCH,DELETE,POST,PUT" },
{ "key": "Access-Control-Allow-Headers", "value": "X-CSRF-Token, X-Requested-With, Accept, Accept-Version, Content-Length, Content-MD5, Content-Type, Date, X-Api-Version" }
]
}
]
}

0 comments on commit c5a24f8

Please sign in to comment.