0

I am new to coding and I have a question about a small app that I created with angular.js that makes a post request to another express.js app. It's a simple parentheses balance checker, you can find the whole code here: https://github.com/OGsoundFX/parentheseschecker

The FrontEnd-Refactored folder contains the Angular.js app and the APItesting contains the express.js API.

The app is working, but I have only been using it locally. The API runs on localhost:3000 and the app on localhost:8080

But what if I want to make it public? How would I go about it? I don't really know where to start. Where to host a node.js of express.js app. I read about AWS, would that be good, or are there better services?

I have a Wordpress website hosted on https://www.mddhosting.com/ but that wouldn't work, right?

My Angular app is calling the api locally at the moment, so I will probably have to change the API link that it is fetching:

ApiService.js

function ApiService($http) {
    API = '//localhost:3000/parentheses';
    this.getUser = (entry) => {
        return $http
            .post(API, { string: entry} )
            .then(function (response) {
                return response.data;
            }, function (reason) {
                // error
            })
    };
};

angular
    .module('app')
    .service('ApiService', ApiService);

In my API server.js

const http = require('http');
const app = require('./app')

const port = process.env.PORT || 3000;

const server = http.createServer(app);
server.listen(port);

I will definitely have to change API = '//localhost:3000/parentheses'; in my AngularJS app, but should I change const port = process.env.PORT || 3000; ?

I just need a little push start to help me clear some confusion. Thanks!

1 Answer 1

2

Ensure you use application-level environment variables For example: To define the BASE_URL of your site for development and production separately. Doing so you don't have to make any configuration changes when you go live, it is a one-time process.

And if you are looking for free hosting services for pet projects Heroku is good and if you really want to make site go live for the end-users you may go for AWS EC2 instance or Heroku paid service both are good.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks a lot, that sounds good! I will have a look at setting application-level environment variables, as a start and take it from there I will get back to you, thanks!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.