3

I am using UI-Router for routes/states in my app and URLs were having "#" so to remove this , I used $locationProvider like -

function configState($stateProvider, $urlRouterProvider, $locationProvider) {

    $locationProvider.html5Mode(true);

Added ngRoute in module dependency and added <base href="/" > in my index.html.

Problem -

If I am using it as a normal app like in same tab and navigates to other state, it works BUT whenever I pasted the URL in another tab and hit enter its throwing Cannot GET /app_views/contacts URL is like - http://localhost:9000/app_views/contacts

Though with hash in URL it works in both way manner.

1 Answer 1

2

You are likely getting this error because your server is not configured correctly. In other words when you manually enter /app_views/contacts it will make a request to the server for that page. For this to work properly you need configure your server to route all traffic to your index.html page in order for Angular to properly take over and display the correct view.

Here is a related post Reloading the page gives wrong GET request with AngularJS HTML5 mode

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

4 Comments

What kind of server are you using?
I am simply running a bootstrap theme wrapbootstrap.com/theme/homer-responsive-admin-theme-WB055J451 and in docs its mention to run it via grunt live command after installing grunt-cli
Hmm well in that case I am assuming it is a node.js server. You are still going to have to fix it server side. You can probably dig in there and find how the app is being served. You will need to do something like this stackoverflow.com/a/18214539/3075624 Once again I am only assuming this is a node server, it will be slightly different depending on what server you are using but regardless you have to point everything to you entry point which is most likely your index.html page.
I think I need to look at some grunt task....thx for the help :) +1 and added a tick

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.