From b07cbae11231d424861122741419a7300758addd Mon Sep 17 00:00:00 2001 From: Pelayo-Reguera Date: Thu, 4 May 2023 03:58:46 +0200 Subject: [PATCH] Try without the customized cors --- .github/workflows/lomap_en3a.yml | 34 ++++++++++++++++---------------- restapi/api.ts | 14 +------------ restapi/server.ts | 7 +++---- 3 files changed, 21 insertions(+), 34 deletions(-) diff --git a/.github/workflows/lomap_en3a.yml b/.github/workflows/lomap_en3a.yml index 0248f78b..03ad9c96 100644 --- a/.github/workflows/lomap_en3a.yml +++ b/.github/workflows/lomap_en3a.yml @@ -70,20 +70,20 @@ jobs: password: ${{ secrets.DOCKER_PUSH_TOKEN }} registry: ghcr.io workdir: restapi - deploy: - name: Deploy over SSH - runs-on: ubuntu-latest - needs: [docker-push-restapi,docker-push-webapp] - steps: - - name: Deploy over SSH - uses: fifsky/ssh-action@master - with: - host: ${{ secrets.DEPLOY_HOST }} - user: ${{ secrets.DEPLOY_USER }} - key: ${{ secrets.DEPLOY_KEY }} - command: | - wget https://raw.githubusercontent.com/arquisoft/lomap_en3a/deployment-ivan/docker-compose-deploy.yml -O docker-compose.yml - docker-compose stop - docker-compose rm -f - docker-compose pull - docker-compose up -d \ No newline at end of file +# deploy: +# name: Deploy over SSH +# runs-on: ubuntu-latest +# needs: [docker-push-restapi,docker-push-webapp] +# steps: +# - name: Deploy over SSH +# uses: fifsky/ssh-action@master +# with: +# host: ${{ secrets.DEPLOY_HOST }} +# user: ${{ secrets.DEPLOY_USER }} +# key: ${{ secrets.DEPLOY_KEY }} +# command: | +# wget https://raw.githubusercontent.com/arquisoft/lomap_en3a/deployment-ivan/docker-compose-deploy.yml -O docker-compose.yml +# docker-compose stop +# docker-compose rm -f +# docker-compose pull +# docker-compose up -d \ No newline at end of file diff --git a/restapi/api.ts b/restapi/api.ts index b63f0606..91a9e084 100644 --- a/restapi/api.ts +++ b/restapi/api.ts @@ -1,20 +1,8 @@ import express, { Router } from 'express'; import {getPlaces, addPlace, deletePlace, updatePlace, findPlaceByTitle} from "./src/controllers/places/PlacesController"; -import {addPlaceChecks, deletePlaceChecks, updatePlaceChecks, findPlaceByTitleChecks} from "./src/controllers/checks" -import cors from "cors"; +import {addPlaceChecks, deletePlaceChecks, updatePlaceChecks, findPlaceByTitleChecks} from "./src/controllers/checks"; const api:Router = express.Router() -let hostIp: string = "20.168.251.141"; - -api.use( - cors({ - credentials: true, - origin: ["https://20.168.251.141", "https://lomapen3a.cloudns.ph", "https://localhost", - "https://20.168.251.141:443", "https://lomapen3a.cloudns.ph:443", "https://localhost:443"], - allowedHeaders: ["Content-Type", "Authorization"], - preflightContinue: true, - }) -); api.get("/places/list", getPlaces); api.post("/places/add", addPlaceChecks, addPlace); diff --git a/restapi/server.ts b/restapi/server.ts index f3ab8aa4..b3f14986 100644 --- a/restapi/server.ts +++ b/restapi/server.ts @@ -22,15 +22,14 @@ mongoose.connect(uri, options).then( const metricsMiddleware:RequestHandler = promBundle({includeMethod: true}); app.use(metricsMiddleware); +app.use(cors()); app.use(bp.json()); app.use("/api", api) try { - // let privateKey = readFileSync("claves/privkey.pem"); - // let certificate = readFileSync("claves/fullchain.pem"); - let privateKey = readFileSync("claves/alice.key"); - let certificate = readFileSync("claves/alice.crt"); + let privateKey = readFileSync("claves/privkey.pem"); + let certificate = readFileSync("claves/fullchain.pem"); let credentials = { key: privateKey, cert: certificate }; app.all('*', function(req, res, next){