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
 describe("Our app", () => {
1
 describe("Our app", () => {
2
   beforeEach(() => {
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
     cy.viewport("iphone-x");
17
     cy.viewport("iphone-x");
12
     cy.visit("/");
18
     cy.visit("/");

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

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

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

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