Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How about mod rewrite? #17

Open
ghost opened this issue Dec 11, 2014 · 7 comments
Open

How about mod rewrite? #17

ghost opened this issue Dec 11, 2014 · 7 comments

Comments

@ghost
Copy link

ghost commented Dec 11, 2014

In case I have a file called app/index.html to start the app,
given that I am using html5mode in angularjs,
how can I access the site directly using localhost:8000 instead of localhost:8000/app/index.html?

Please help and thanks!

@leeluolee
Copy link
Owner

I also consider the mod rewirte is useful.

I guess you may need this .

where in route.js

   module.exports = {
       "GET /**": "app/index.html"
   }

then

puer -a ./route.js

@leeluolee
Copy link
Owner

Maybe today , I will update the puer to implement the simple static mod rewrite

@ghost
Copy link
Author

ghost commented Dec 11, 2014

It shows this when I use "GET /**": "app/index.html"

.get() requires callback functions but got a [object String]

@leeluolee
Copy link
Owner

@yhjor1212 because, it hasn't been implemented yet . :)

I push the commit to github right now , but haven't release it to npm. you can npm install it through github temporarily

npm install leeluolee/puer -g

the code

module.exports = {
       "GET /**": "app/index.html"
   }

will make the all path begin with '/' point to the app/index.html file. which can make your angularjs app works on html5mode .

@ghost
Copy link
Author

ghost commented Dec 12, 2014

The error message indeed disappeared, but the reload still doesn't work:

access http://localhost:5000/pending1
get: Cannot GET /pending1

@ghost ghost closed this as completed Dec 12, 2014
@leeluolee
Copy link
Owner

maybe you should show your configuration , so I can track the issue easily . @yhjor1212

@ghost ghost reopened this Dec 16, 2014
@ghost
Copy link
Author

ghost commented Dec 16, 2014

  • Start server
    puer -p 5000 -a scripts/route.js

  • Application root
    app/index.html

  • Angular js route settings
    angular.module('myApp.routes', ['ui.router'])
    .config(['$stateProvider', '$urlRouterProvider', '$locationProvider', function($stateProvider, $urlRouterProvider, $locationProvider) {
    $urlRouterProvider.otherwise("/home");

    $stateProvider
    .state('home', {
    url: "/home",
    templateUrl: "app/partials/home.html",
    controller: 'HomeCtrl'
    })
    ...

$locationProvider.html5Mode(true);

  • scripts/route.js
    module.exports = {
    "GET /**": "app/index.html"
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant