Having trouble connecting my Express.js API to Angular6. My server setup seems to be causing the issue

After uploading my Angular app on Godaddy Host in the public_html directory, I also included the Express.js API in the public_html/web-api folder. When it comes to running node on the host using SSH, everything seems to work fine as indicated by the console log showing the initialization of the database here. However, when trying to access the API through requests, it appears that Angular does not redirect properly and there is no output in the SSH console. What could be missing from my environment settings and proxy configuration for production? Locally, I never encountered such issues before. Do I need to specify the port or the folder where my API resides?

//environment.prod
export const environment = {
  production: true, 
  apiUrl: ['https://web.com'],
};

{

  "/api/*": {
    "target": "https://web.com/web-api",
    "secure": false,
    "logLevel": "debug",
    "changeOrigin": true

  }
}

Files on the host: public_html

directory: web-api

Any assistance provided would be greatly appreciated!!!

Answer №1

In my local setup, I configured the API port as follows:

//Proxy.conf.json
 {
  "/api/*": {
    "target": "http://localhost:3000",
    "secure": false,
    "logLevel": "debug",
    "changeOrigin": true
  }
}

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

An error occurred as the requested resource does not have the necessary 'Access-Control-Allow-Origin' header. The response code received was 403

I am working with Angular products services that make calls to the "http://jsonplaceholder.typicode.com/posts" URL using the HttpClient method. However, I am encountering the error message "No 'Access-Control-Allow-Origin' header is present on t ...

A problem arises when making a basic express request

I'm encountering a frustrating problem with Express and Nodejs, I have a simple code that allows me to check if the headers exist in the request or not : var express = require('express'); var app = express(); app.get('/', funct ...

Managing the sequence of module loading in NodeJS

Consider this scenario: There are 3 files (modules) involved: app.js (async () => { await connectoDB(); let newRec = new userModel({ ...someprops }); await newRec.save(); })(); The app.ts serves as the entry point of the project. database ...

What is the best way to add a clickable link/button in Angular 8 that opens a webpage in a new tab?

I'm looking to create a website that opens in a new tab when a link or button is clicked. I'm unsure how to achieve this in Angular 8. ...

The functionality of connect-flash in Express JS is compromised when used in conjunction with express-mysql-session

I am facing a unique issue in my project. I have identified the source of the problem but I am struggling to find a solution. My project utilizes various modules such as cookie-parser, express-mysql-session, express-session, connect-flash, passport and m ...

Retrieving Referrer and Other Data from Node.js Express Request Headers

After receiving a post from a payment gateway via https to verify a payment, I am faced with the task of confirming that the origin is indeed from the designated domain. I'm attempting to validate that the referrer is included in a specific list of d ...

Create a Typescript function that adheres to a specified type

Imagine a scenario where a specific type of function is declared within a type type Callback = (err: Error | null, result: any) type UselessFunction = (event: string, context: any, callback: Callback) => void The objective is to declare functions that ...

Issue with Node.js filesystem operations results in server error 500

While working on a project with node express framework and ajax, I encountered a 500 server error on the front-end side. The server-side code is quite simple, as shown below in the express router. However, as soon as I introduced some code related to fil ...

Issue: Unable to ascertain a GraphQL input type in Nestjs + Graphql + Typeorm configuration

I'm currently exploring Nestjs, Graphql, and Typeorm for the first time. However, I've encountered a roadblock where I am unable to resolve an issue. Specifically, I'm using the @ManyToOne relationship to connect food with a user, but I keep ...

Node.js encountering installation error with Express.js

Encountered an issue while attempting to install express.js using the command "npm install -g express" in the Windows command prompt, resulting in the following error: module.js:340 throw err; ^ Error: Cannot find module 'express' ...

Passing a retrieved parameter from the URL into a nested component in Angular

I'm currently facing an issue where I am trying to extract a value from the URL and inject it into a child component. While I can successfully retrieve the parameter from the URL and update my DOM with a property, the behavior changes when I attempt t ...

Utilizing the all() function in an express server

While reviewing the express framework documentation, I came across a method called "all()" on an express server. From what I gather, this method is used to pre-fetch objects so that when a CRUD operation request arrives later, the response time would be ...

Choose particular spreadsheets from the office software

My workbook contains sheets that may have the title "PL -Flat" or simply "FLAT" I currently have code specifically for the "PL -Flat" sheets, but I want to use an if statement so I can choose between either sheet since the rest of the code is identical fo ...

Incorporating Node.js with Passport and Express

I am currently working on a middleware to extract the details of the logged-in user. I have set res.locals.currentUser=req.user in the middleware, but for some reason, req.user is showing undefined even after the user has successfully logged in. Below is ...

How to properly handle string escaping within a JSON object

When I send this object as JSON response, it includes double backslashes in the URL. {"__type":"http:\/\/example.com\/contracts\/documents\/rendering\/instructions\/1\/0"} My desired response is: {"__type":"http:& ...

What are the steps to modify the authorization header of an HTTP GET request sent from a hyperlink <a href> element?

I have a unique Angular application that securely saves JWT tokens in localstorage for authentication purposes. Now, I am eager to explore how to extract this JWT token and embed it into an HTTP GET request that opens up as a fresh web page instead of disp ...

Incorporating Moralis into Ionic Angular with TypeScript

I'm currently developing an app using Ionic Angular (TypeScript) that will be compatible with both Android and iOS devices. I've decided to incorporate the Moralis SDK to establish a connection with the Metamask wallet. Here's a summary of ...

Troubleshooting problem with sorting in Angular 4 material header

Using Angular 4 material for a table has presented me with two issues: 1. When sorting a table, it displays the description of the sorting order in the header. I would like to remove this. https://i.sstatic.net/5bHFO.png It displays "Sorted by ascending o ...

Acquiring POST parameters in Express.js version 3

Just embarking on my journey with node and express.js, I am encountering some difficulties when it comes to handling a POST request. My objective is to post information that will later be logged in an activity log. The structure of the request is as follow ...

Managing configurations in a nodejs application

During my exploration of open-source software, I stumbled upon a straightforward statement: if ('development' == app.get('env')){ app.use(express.errorHandler()); } It seems like app.get is looking at environment variables on my sys ...