Browse Source

[fix] Fix CORS issue

Sergio Mattei 1 year ago
parent
commit
27ad2ea2af
3 changed files with 17 additions and 11 deletions
  1. 13
    7
      cypress/e2e/sergio.cy.ts
  2. 3
    3
      src/pages/AdviceListPage.tsx
  3. 1
    1
      src/pages/ArticlePage.tsx

+ 13
- 7
cypress/e2e/sergio.cy.ts View File

@@ -1,12 +1,18 @@
1 1
 describe("Our app", () => {
2 2
   beforeEach(() => {
3
-    cy.intercept("GET", "http://localhost:3000/api/getTopicList/*", {
4
-      fixture: "topics",
5
-    }).as("getTopicList");
6
-
7
-    cy.intercept("GET", "http://localhost:3000/api/getTopic/*", {
8
-      fixture: "article",
9
-    }).as("getTopic");
3
+    cy.intercept(
4
+      { pathname: "/api/getTopicList" },
5
+      {
6
+        fixture: "topics",
7
+      }
8
+    ).as("getTopicList");
9
+
10
+    cy.intercept(
11
+      { pathname: "/api/getTopic" },
12
+      {
13
+        fixture: "article",
14
+      }
15
+    ).as("getTopic");
10 16
 
11 17
     cy.viewport("iphone-x");
12 18
     cy.visit("/");

+ 3
- 3
src/pages/AdviceListPage.tsx View File

@@ -14,15 +14,15 @@ import { Topic } from "../types";
14 14
 
15 15
 const AdviceListPage: React.FC = () => {
16 16
   const { data: paternidad, error: paternidadError } = useSWR<Topic[]>(
17
-    "/api/getTopicList/?type=advice&category=Paternidad",
17
+    "/api/getTopicList?type=advice&category=Paternidad",
18 18
     fetcher
19 19
   );
20 20
   const { data: matrimonio, error: matrimonioError } = useSWR<Topic[]>(
21
-    "/api/getTopicList/?type=advice&category=Matrimonio",
21
+    "/api/getTopicList?type=advice&category=Matrimonio",
22 22
     fetcher
23 23
   );
24 24
   const { data: abuso, error: abusoError } = useSWR<Topic[]>(
25
-    "/api/getTopicList/?type=advice&category=Abuso%20Sexual",
25
+    "/api/getTopicList?type=advice&category=Abuso%20Sexual",
26 26
     fetcher
27 27
   );
28 28
   const error = paternidadError || matrimonioError || abusoError;

+ 1
- 1
src/pages/ArticlePage.tsx View File

@@ -23,7 +23,7 @@ const ArticlePage: React.FC<RouteComponentProps<{ articleId: string }>> = ({
23 23
   match,
24 24
 }) => {
25 25
   const { data, error } = useSWR<any>(
26
-    `/api/getTopic/?id=${match.params.articleId}`,
26
+    `/api/getTopic?id=${match.params.articleId}`,
27 27
     fetcher
28 28
   );
29 29
   const isLoading = !data && !error;