Skip to content

Commit

Permalink
resolve the CORS
Browse files Browse the repository at this point in the history
  • Loading branch information
Punvireakroth committed Nov 30, 2023
1 parent da9e7c0 commit d818487
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 1 deletion.
1 change: 1 addition & 0 deletions client/src/components/Grid/DataGrid.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ function DataGridComponent() {
try {
const response = await fetch("https://survey-api-dj9k.onrender.com/api/surveys/", {
method: "GET",
mode: 'no-cors',
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${user.token}`,
Expand Down
3 changes: 2 additions & 1 deletion client/src/components/Survey/CreateSurvey/CreateSurvey.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ const CreateSurvey = (props) => {

const startSurvey = () => {
if (id) {
callApiToGetSurvey(`https://survey-api-dj9k.onrender.com/api/surveys/${id}`, { method: "GET" });
callApiToGetSurvey(`https://survey-api-dj9k.onrender.com/api/surveys/${id}`, { method: "GET", mode: 'no-cors', });
setEditingPreviousSurvey(true);
} else {
setSurvey({ ...survey, _id: uniqid("survey-"), user_id: user.token });
Expand Down Expand Up @@ -158,6 +158,7 @@ const CreateSurvey = (props) => {
}
const response = await fetch("https://survey-api-dj9k.onrender.com/api/surveys/create-update", {
method: "POST",
mode: 'no-cors',
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${user.token}`,
Expand Down
2 changes: 2 additions & 0 deletions client/src/components/Survey/DisplaySurvey/DisplaySurvey.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ const DisplaySurvey = (props) => {

callApi(`/api/surveys/${id}`, {
method: "GET",
mode: 'no-cors',
});
}, [user, id]);

Expand Down Expand Up @@ -182,6 +183,7 @@ const DisplaySurvey = (props) => {
`https://survey-api-dj9k.onrender.com/api/surveys/update-responses/${survey._id}`,
{
method: "PUT",
mode: 'no-cors',
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${user.token}`,
Expand Down
1 change: 1 addition & 0 deletions client/src/components/Survey/DisplaySurveyList.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,7 @@ const DisplaySurveyList = (props) => {
try {
const reponse = await fetch(`https://survey-api-dj9k.onrender.com/api/surveys/delete/${surveyIdToDelete}`, {
method: "DELETE",
mode: 'no-cors',
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${user.token}`,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export default function DisplayResult() {
useEffect(() => {
callApi(`api/surveys/${id}`, {
method: "GET",
mode: 'no-cors',
});
}, [user, id]);

Expand Down
1 change: 1 addition & 0 deletions client/src/hooks/useLogin.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export const useLogin = () => {

const response = await fetch("https://survey-api-dj9k.onrender.com/user/login", {
method: "POST",
mode: 'no-cors',
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ email, password, role }),
});
Expand Down
1 change: 1 addition & 0 deletions client/src/hooks/useSignup.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export const useSignup = () => {

const response = await fetch("https://survey-api-dj9k.onrender.com/user/signup", {
method: "POST",
mode: 'no-cors',
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ email, password, role }),
});
Expand Down

1 comment on commit d818487

@vercel
Copy link

@vercel vercel bot commented on d818487 Nov 30, 2023

Choose a reason for hiding this comment

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

Successfully deployed to the following URLs:

survey – ./client

survey-git-main-punvireakroth.vercel.app
survey-dun-theta.vercel.app
survey-punvireakroth.vercel.app

Please sign in to comment.