2016-10-12 5 views
0

すべての反応アプリリクエストに同じjs/bundle.jsファイルで応答する必要がありますが、実際のリダイレクトはしません。なぜなら、bundle.jsが返ってくると、反応ルータはこのbundle.jsファイルから必要なページを取得するからです。ApacheはURLに2つ以上のスラッシュを含む反応リクエストを正しくリダイレ​​クトしません

URLに「/」が1つある場合は、ページ/welcomeを再読み込みするか、それ以外の場合は正常に動作します。

/auth/login(2つのスラッシュ)をリロードしようとすると、bundle.jsauth/js/bundle.jsから見つかるとエラーが発生します。

私は

RewriteEngine on 
    # Don't rewrite files or directories 
    RewriteCond %{REQUEST_FILENAME} -f [OR] 
    RewriteCond %{REQUEST_FILENAME} -d 
    RewriteRule^- [L] 
    # Rewrite everything else to index.html to allow html5 state links 
    RewriteRule^/index.html [L] 

を使用しています。しかし、それは助けにはなりません。ここ
は、任意の助けを事前に私の反応-ルータを

function requireAuth(nextState, replace) { 
    if (!localStorage.mazoomToken) { 
     replace({ 
      pathname: '/auth/login', 
      state: { nextPathname: nextState.location.pathname } 
     }) 
    } 
} 

function hasAuth(nextState, replace) { 
    if (localStorage.mazoomToken) { 
     replace({ 
      pathname: '/', 
      state: { nextPathname: nextState.location.pathname } 
     }) 
    } 
} 

const router = (
    <Provider store={store}> 
     <Router history={history}> 
      <Route path="/" onEnter={requireAuth} component={App}> 
       <IndexRoute component={Events}/> 
       <Route path="welcome" component={WelcomePage} onEnter={requireAuth}/> 
       <Route path="contacts" component={Contacts} onEnter={requireAuth}/> 
       <Route path="profile" component={Account} onEnter={requireAuth}/> 
      </Route> 

      <Route path="/auth/" component={Auth} onEnter={hasAuth}> 
       <Route path="sign_up" component={SignUp} onEnter={hasAuth}/> 
       <Route path="login" component={Login} onEnter={hasAuth}/> 
       <Route path="forgot_pass" component={ForgotPassword} onEnter={hasAuth}/> 
       <Route path="password/:token" component={NewPassword} onEnter={hasAuth}/> 
      </Route> 
     </Router> 
    </Provider> 
); 

感謝です!

答えて

0

問題はindex.htmlにありました。スクリプトjs/bundle.jsをリンクするとき、私はjs - /js/index.jsの前にスラッシュを入れませんでした。

関連する問題