Angular Front End for Time-stamp Micro-service?

Angular Front End for Time-stamp Micro-service?
0.0 0

#1

Hello everyone, I’m currently working on the time-stamp micro-service back end project and I’ve hit a snag.

I know it would be a lot easier to not use any front-end framework for the landing page, but I’m trying to get some practice with Angular v1.

I’ll start by saying that my front-end and back-end are not in the same file structure, and are not going to be on the same server as I’ve read that it is a good practice to separate front and back-end code. My back-end (node + express) is on Heroku and I plan on deploying the front-end to surge.

Here’s the problem I’m having; when I type the complete URL into the address bar in my browser a “cannot get /someNumber” error appears. I’ve spent the last day and a half working on this with no luck.

Things to note:

    1. I know a get request to ‘/’ works fine because I do receive the proper view in my browser.
    1. My api is “RESTful”, so I am only sending back json responses. The problem with this is that some of the solutions for the problem I’m having say to make a get’/*’ route in express and redirect all traffic to index.html. However since my html document and my express files aren’t on the same server, I can’t figure out how to do that (if it’s even possible?).
    1. I can get the proper response from the server if I type “/#!someNumber” into the address bar, however the instructions for the project say that the URL should only accept “/someNumber” with no #!.
    1. I’ve tried using $location in the controller to grab the URL then modify it, but no luck.

What would be the best way to go about solving this? The next step I was going to try was to create an interceptor or use transformRequest to grab the URL (which would be in the form of ‘/someNumber’,) and change it to ‘/#!someNumber’ before sending it to the server.

Or maybe I’m going about this all wrong. Any help would be appreciated! Thanks!


#2

I can’t see your code so can’t say much.

What i used to make the css and js within same directory work, is the following function:

app.use("/", express.static(__dirname + ‘/’));
// after declaring the following:
// var express = require(“express”);
// var app = express();

to include the css that is within the same directory, this also runs my index html. So it might work if you try this?


#3

Sorry about that, I was in a hurry when I made my initial post. Here are the links to the repos:

Back End Github

Front End Github
(Try to ignore all the comments and overall crappiness of the format of the Front-End code. I was so exhausted and annoyed after tying so many different things I was in a hurry to write it all.)