0
すべての反応アプリリクエストに同じjs/bundle.js
ファイルで応答する必要がありますが、実際のリダイレクトはしません。なぜなら、bundle.js
が返ってくると、反応ルータはこのbundle.js
ファイルから必要なページを取得するからです。ApacheはURLに2つ以上のスラッシュを含む反応リクエストを正しくリダイレクトしません
URLに「/」が1つある場合は、ページ/welcome
を再読み込みするか、それ以外の場合は正常に動作します。
/auth/login
(2つのスラッシュ)をリロードしようとすると、bundle.js
がauth/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>
);
感謝です!