表达modrewrite https和静态文件

时间:2015-07-23 06:16:40

标签: node.js mod-rewrite express

我需要对我的后端进行快速重定向/重写(仅在特定端口上接受https)并且还要继续提供静态文件(前端),但似乎我有错误..

 var express = require('express');
var app = express();
var modRewrite = require('connect-modrewrite');


app.use("/",express.static(__dirname + "/build"));

app.use(modRewrite([
  '^/auth/signin https://127.0.0.1:8444/auth/signin'
]));

var server = app.listen(8000, function () {
  var host = server.address().address;
  var port = server.address().port;

  console.log('App listening at http://%s:%s', host, port);
});

1 个答案:

答案 0 :(得分:1)

请更改



public class PMRouteBuilder extends RouteBuilder {
UserProfileResponseProcessor responseProcessor=new UserProfileResponseProcessor();
         System.out.println("\n");
         System.out.println("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX");
         System.out.println("           STARTED PROCESS MANAGER ROUTEBUILDER                          ");
         System.out.println("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX");
try{
             from("cxf:bean:process-manager-ws?dataFormat=POJO").routeId("process-manager-route-userprofile").log( "This is ${in.header.operationName} operation called...." )
                    .log( "Entering inside the Choice with operation....${in.header.operationName}")
                    //.wireTap(RouterEndPoints.ENDPOINT_AUDITOR_QUEUE.value(),true, new PreWireTapProcessor())
                    .choice()
                        /**
                         * ##################################### ROUTE FOR USER PROFILE REQUEST ###########################################
                         */
                        .when(simple("${in.header.operationName} == 'retrieveUserProfile'"))
                            .to("log:?showAll=true&multiline=true")
                            .setHeader("OPERATION_NAME", constant("retrieveUserProfile") )
                            .process(pmRequestProcessor)
                            .log( "Setting header value to...."+constant(AuditActions.Actions.ACTION_GET_USER_PROFILE.desc()) )
                            .setHeader(RouteActions.Actions.OMGMEAT_ACTION_ID.desc(), constant(AuditActions.Actions.ACTION_GET_USER_PROFILE.desc())).convertBodyTo(UserProfile.class)
                            .to(RouterEndPoints.ENDPOINT_USERPROFILE_QUEUE.value()).process(responseProcessor)
                        .when(simple("${in.header.operationName} == 'addUserProfile'"))
                            .log( "Setting header value to...."+constant(AuditActions.Actions.ACTION_ADD_PROFILE.desc()) )
                            .setHeader(RouteActions.Actions.OMGMEAT_ACTION_ID.desc(), constant(AuditActions.Actions.ACTION_ADD_PROFILE.desc())).convertBodyTo(UserProfile.class)
                            .to(RouterEndPoints.ENDPOINT_USERPROFILE_QUEUE.value()).process(responseProcessor)
.end()
 }catch(Exception exc){
             ApplicationLogger.error("PMRouteBuilder.configure():Exception while configure the route for 'cxf:bean:process-manager-ws?dataFormat=POJO'",exc);
         }

app.use(modRewrite(['^/auth/signin https://127.0.0.1:8444/auth/signin']));

从文件中: https://www.npmjs.com/package/connect-modrewrite#proxy-p

app.use(modRewrite(['^/auth/signin https://127.0.0.1:8444/auth/signin [P]']));