Search Posts

Category: express

AngularJS SPA needs to reload to recognize the jwt token in localstorage

how to AngularJS SPA needs to reload to recognize the jwt token in localstorage everything good ? Today I need your help to solve a token authentication problem (jwt) in my SPA AngularJS application (I use NodeJS in the backend). When I log in, the credentials are validated in the backend and if I succeed I get a token that is stored in localstorage. But when I start making my requests to the protected endpoints […]

load mongo information to my own front-end table

how to load mongo information to my own front-end table I create my table with angular but whem i try i put the information here doesn’t appear and i don’t know why doesn’t have errors but the information but i can see the information and i read the information and the information appear. I put my code down with hope to some one can help me PD: sorry for my bad english. 😀 student-service.ts @Injectable() […]

CSRF protection in angular js application with cross domain

My APIs are running in api.domain.com and frontend angular application is running under frontend.domain.com CSRF implementation Enabled CORS on my api.domain.com and access allowed only from frontend.domain.com. CSRF token is set in a custom response header called X-CSRFTOKEN In Angular app, first it will make a request to get the CSRF token and attach it with the request header for every post request //get CSRF token $http.get(“http://localhost:3000/”).then(function (response) { console.log(response.headers(‘X-CSRFTOKEN’)); var request = { method: […]

How can I create vhost for my application on express server?

App just created in angualrjs1 and I don’t know how to create vhost for this. Here is my code. Any solution would be appreciated. Now it is running on localhost:3000 But I want to run like : dev.domain.com var express = require(‘express’), logger = require(‘./lib/logger’), app = express(), bodyParser = require(‘body-parser’), cors = require(‘cors’), http2https = require(‘./middleware/http2httpsMiddleware’), corsMiddleware = require(‘./middleware/corsMiddleware’), logRequest = require(‘./middleware/loggerMiddleware’).logRequest, logErrors = require(‘./middleware/loggerMiddleware’).logErrors, routes = require(‘./router.js’)(express.Router()); var vhost = require(‘vhost’); app.use(bodyParser.json()); app.use(bodyParser.urlencoded({extended: […]

Express basic-auth-connect also protects bower

I am working on an Express+Angular SPA. I am trying to use “basic-auth-connect” as an additional authentication mechanism to restrict access to the login page to selected people. I have a different auth mechanism for logging into the app itself. I don’t want to protect any routes, just the login page to which angular redirects. So I just plug the basic-auth middleware before the express.static middleware. app.use(bodyParser.urlencoded({ extended: true })); app.use(bodyParser.json()); app.use(‘/signup’, signup); app.use(‘/login’, login); […]

With Express and Angular, how can I receive the results of a search in the front end javascript file so I can filter the results?

I understand how to receive the information with eJS or Jade, but I don’t know how to get it to the Front End Javascript. Currently the workflow of the Website is the user clicking on the ‘See All NPC’ to see the data without a filter. This looks like website.com/NPC/?s=. The user can use a search bar on the page to reload the page as website.com/NPC/?s=. Currently I display the data with Angular from the […]

One mean-stack project for 2 websites

I have one mean-stack project which serves at the moment 2 set of web pages: www.myweb.com/… (except key) and www.myweb.com/ABC/…. I decided to manage them in one project because they have common things to share. For example, they can share some JS files including controllers and providers, while their html files are quite different. They share one database as well. Now, I realise that this approach has some fundamental conflicts. So I’m trying to split […]

reloading the deep route after removing the ‘#’ from url in express angular app throwing error

I tried to remove the hashtag from url in angular app. Issue: The redirection works perfectly if I first load the index page and then goto any route, however, it throws an error when I reload any deep route page directly. If I refresh any page : localhost:3001/about, It throws error however when I route from index page <a href=”/about”>About </a> it works. I checked many answers for modrewrite, however, none worked for me. In […]

Routing with AngularJS and Express

I am trying to use AngularJS ngRoute along side Express but I keep getting the following error: cannot Get /profile Here’s my code: .config([‘$locationProvider’, ‘$routeProvider’, function ($locationProvider, $routeProvider) { $routeProvider.when(‘/profile’, { templateUrl: ‘views/partials/profile.html’, controller: ‘kontrola’ }) $locationProvider.html5Mode(‘true’) $locationProvider.hashPrefix(‘!’) app.get(‘/’, routes.index) app.get(‘/login’, routes.login) app.get(‘/signup’, routes.signup) How can I fix it? Source: AngularJS

Express redirect before Angular app loads

Case When I visit my url https://example.com/ my angular application loads and the url adds the hash-routing to https://example.com/#/. My angular code checks for user credentials from a saml url and doesn’t find anything, so it calls passport login which then takes me to my SAML login page (company hosted) which returns me back to my homepage again with the proper user details. My question is around being able to prevent angular app from loading […]

Next Page »