From 98ef40ffd6560926e27098c0c922f7f8b0f2eae9 Mon Sep 17 00:00:00 2001 From: Saad Jutt Date: Wed, 10 Nov 2021 08:33:44 +0500 Subject: [PATCH] chore: server issue fix --- api/src/prod-server.ts | 4 ++-- package.json | 2 ++ web/src/components/login.tsx | 33 ++++++++++++++------------------- 3 files changed, 18 insertions(+), 21 deletions(-) diff --git a/api/src/prod-server.ts b/api/src/prod-server.ts index e652e39..1a4ce4a 100644 --- a/api/src/prod-server.ts +++ b/api/src/prod-server.ts @@ -4,8 +4,8 @@ import * as https from 'https' import { configuration } from '../package.json' import app from './app' -const keyPath = path.join('certificates', 'privkey.pem') -const certPath = path.join('certificates', 'fullchain.pem') +const keyPath = path.join('..', 'certificates', 'privkey.pem') +const certPath = path.join('..', 'certificates', 'fullchain.pem') const key = readFileSync(keyPath) const cert = readFileSync(certPath) diff --git a/package.json b/package.json index 6e9edb8..744067c 100644 --- a/package.json +++ b/package.json @@ -3,6 +3,8 @@ "version": "0.0.1", "description": "NodeJS wrapper for calling the SAS binary executable", "scripts": { + "server:install": "cd web && npm ci && cd ../api && npm ci", + "server": "cd web && npm run build && cd ../api && npm run start:prod", "lint-api:fix": "npx prettier --write \"api/src/**/*.{ts,tsx,js,jsx,html,css,sass,less,yml,md,graphql}\"", "lint-api": "npx prettier --check \"api/src/**/*.{ts,tsx,js,jsx,html,css,sass,less,yml,md,graphql}\"", "lint-web:fix": "npx prettier --write \"web/src/**/*.{ts,tsx,js,jsx,html,css,sass,less,yml,md,graphql}\"", diff --git a/web/src/components/login.tsx b/web/src/components/login.tsx index b352eb7..7da52a0 100644 --- a/web/src/components/login.tsx +++ b/web/src/components/login.tsx @@ -1,30 +1,25 @@ -import axios from 'axios' import React, { useState } from 'react' import PropTypes from 'prop-types' import { CssBaseline, Box, TextField, Button } from '@mui/material' const getAuthCode = async (credentials: any) => { - return axios - .post('/SASjsApi/auth/authorize', { - method: 'POST', - headers: { - 'Content-Type': 'application/json' - }, - body: JSON.stringify(credentials) - }) - .then((data: any) => data.json()) + return fetch('/SASjsApi/auth/authorize', { + method: 'POST', + headers: { + 'Content-Type': 'application/json' + }, + body: JSON.stringify(credentials) + }).then((data) => data.json()) } const getTokens = async (payload: any) => { - return axios - .post('/SASjsApi/auth/token', { - method: 'POST', - headers: { - 'Content-Type': 'application/json' - }, - body: JSON.stringify(payload) - }) - .then((data: any) => data.json()) + return fetch('/SASjsApi/auth/token', { + method: 'POST', + headers: { + 'Content-Type': 'application/json' + }, + body: JSON.stringify(payload) + }).then((data) => data.json()) } const Login = ({ setTokens }: any) => {