英文:
Add an express use handler that changes the base route
问题
我有一个Svelte/SvelteKit应用程序。它说你可以像这样使用你的应用程序
import { handler } from './build/handler.js';
app.use(handler);
但我已经在这个Express服务器中有另一个应用程序,例如
app.use(otherhandler)
所以我希望有一种方法可以这样做
app.use('/newapp', svelte)
它可以工作,但是,如果你没有登录,我的Svelte应用程序会自动重定向到/login
。因此,Express应用程序立即重定向到/login
,而我希望它能够跳转到/newapp/login
。有办法做到这一点吗?
英文:
I have a svelte/sveltekit app. It says you could just your app like so
import { handler } from './build/handler.js';
app.use(handler);
But I already have another app in this express server, eg
app.use(otherhandler)
So I was hoping there was a way to do this
app.use('/newapp', svelte)
And it works, but, my svelte app has an auto redirect to /login
if you are not logged in. So then the express app immediately redirects to /login
whereas I was hoping it would go to /newapp/login
. Is there a way to do this?
答案1
得分: 3
当您使用不同的基础路径时,您可能需要通过config.kit.paths.base
来配置,然后可以从$apps/path
导入并添加到各种链接和重定向中(至少在UI中,根据文档所述,这是必要的)。
英文:
When you have a different base, you probably should configure that via config.kit.paths.base
which then can be imported from $apps/path
and added to the various links and redirects (at the very least in the UI this will be necessary, as stated by the docs).
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论