Hosting Vikunja in a subdirectory

Hello!

I am trying to install Vikunja on a test server and have the frontend accessible at http://localhost/vikunja/, however it tries to load resources from absolute URLs such as /js/… and /images/…, resulting in 404s. I’ve tried setting the publicPath in vue.config.js, which fixes the paths in index.html, but the paths in the javascript seem to be unaffected.
Is there any way to set the base URL for the frontend, and if not, is this planned for a future release?

Cheers,
Yannick

Hi Yannick!

What paths are not relative? Setting the publicPath (+rebuild) should be enough.

I’m not sure if this can be made configurable in a reliable way, maybe with some kind of workaround and probably not with all install methods. The problem is we can’t make it relative for everyone since accessing things like /tasks/1234 directly won’t work anymore. The path would need to be changed in the compiled index.html file.

Konrad

Hello,

I’ve tried to install vikunja to https://domain.xyz/intra/todo, but no success so far. I’m using the latest releases. The backend has been installed from the deb package and is running in the default port with the default config. I’m using apache2 and Ubuntu.

I’ve set up the reverse proxy exactly as instructed here: Reverse Proxy | Vikunja. However when I visit or the frontend sends a request to https//domain.xyz/intra/todo/api/v1/info, the backend crashes:

2022/08/31 17:54:37 Using config file: /etc/vikunja/config.yml
2022-08-31T17:54:37.917237034Z: INFO	▶ migration/Migrate 030 Ran all migrations successfully.
2022-08-31T17:54:37.917421663Z: INFO	▶ models/RegisterReminderCron 031 Mailer is disabled, not sending reminders per mail
2022-08-31T17:54:37.917499694Z: INFO	▶ cmd/func2 032 Vikunja version v0.16.0
⇨ http server started on [::]:3456
2022-08-31T17:54:41.912532733Z: - 	▶ echo recover.go:92 [PANIC RECOVER] interface conversion: interface {} is nil, not string goroutine 6 [running]:
github.com/labstack/echo/v4/middleware.RecoverWithConfig.func1.1.1(0x152df38, 0x1000, 0x0, 0x16850c0, 0xc0000c80a0)
	/srv/app/pkg/mod/github.com/labstack/echo/v4@v4.1.17/middleware/recover.go:77 +0x105
panic(0x1275340, 0xc0000c51d0)
	/usr/local/go/src/runtime/panic.go:969 +0x1b9
code.vikunja.io/api/pkg/modules/auth/openid.getProviderFromMap(0xc0006b49c0, 0x13d4426, 0x15, 0x11efd80)
	/go/src/code.vikunja.io/api/pkg/modules/auth/openid/providers.go:95 +0x86d
code.vikunja.io/api/pkg/modules/auth/openid.GetAllProviders(0xc00013c6c0, 0x13d75b9, 0x17, 0xc0000367d0, 0xe)
	/go/src/code.vikunja.io/api/pkg/modules/auth/openid/providers.go:46 +0x1a5
code.vikunja.io/api/pkg/routes/api/v1.Info(0x16850c0, 0xc0000c80a0, 0x0, 0x0)
	/go/src/code.vikunja.io/api/pkg/routes/api/v1/info.go:107 +0x477
github.com/labstack/echo/v4.(*Echo).add.func1(0x16850c0, 0xc0000c80a0, 0x13dde75, 0x1b)
	/srv/app/pkg/mod/github.com/labstack/echo/v4@v4.1.17/echo.go:522 +0x62
github.com/labstack/echo/v4/middleware.CORSWithConfig.func1.1(0x16850c0, 0xc0000c80a0, 0x0, 0x7f5aa25f3280)
	/srv/app/pkg/mod/github.com/labstack/echo/v4@v4.1.17/middleware/cors.go:121 +0x483
github.com/labstack/echo/v4/middleware.RecoverWithConfig.func1.1(0x16850c0, 0xc0000c80a0, 0x0, 0x0)
	/srv/app/pkg/mod/github.com/labstack/echo/v4@v4.1.17/middleware/recover.go:98 +0x142
github.com/labstack/echo/v4/middleware.LoggerWithConfig.func2.1(0x16850c0, 0xc0000c80a0, 0x0, 0x0)
	/srv/app/pkg/mod/github.com/labstack/echo/v4@v4.1.17/middleware/logger.go:117 +0x130
github.com/labstack/echo/v4.(*Echo).ServeHTTP(0xc00000c5a0, 0x1663ca0, 0xc0000dc000, 0xc00013a200)
	/srv/app/pkg/mod/github.com/labstack/echo/v4@v4.1.17/echo.go:633 +0x182
net/http.serverHandler.ServeHTTP(0xc0002600e0, 0x1663ca0, 0xc0000dc000, 0xc00013a200)
	/usr/local/go/src/net/http/server.go:2843 +0xa3
net/http.(*conn).serve(0xc0000c8000, 0x1667de0, 0xc000250000)
	/usr/local/go/src/net/http/server.go:1925 +0x8ad
created by net/http.(*Server).Serve
	/usr/local/go/src/net/http/server.go:2969 +0x36c

goroutine 1 [chan receive]:
code.vikunja.io/api/pkg/cmd.glob..func2(0x1fc6ec0, 0x209e430, 0x0, 0x0)
	/go/src/code.vikunja.io/api/pkg/cmd/web.go:68 +0x1dd
github.com/spf13/cobra.(*Command).execute(0x1fc6ec0, 0xc0001101b0, 0x0, 0x0, 0x1fc6ec0, 0xc0001101b0)
	/srv/app/pkg/mod/github.com/spf13/cobra@v1.1.1/command.go:854 +0x2c2
github.com/spf13/cobra.(*Command).ExecuteC(0x1fc6ec0, 0x44dfca, 0x1fe3f60, 0xc000000300)
	/srv/app/pkg/mod/github.com/spf13/cobra@v1.1.1/command.go:958 +0x375
github.com/spf13/cobra.(*Command).Execute(...)
	/srv/app/pkg/mod/github.com/spf13/cobra@v1.1.1/command.go:895
code.vikunja.io/api/pkg/cmd.Execute()
	/go/src/code.vikunja.io/api/pkg/cmd/cmd.go:44 +0x31
main.main()
	/go/src/code.vikunja.io/api/main.go:22 +0x25

goroutine 21 [select]:
database/sql.(*DB).connectionOpener(0xc000280d00, 0x1667de0, 0xc000333700)
	/usr/local/go/src/database/sql/sql.go:1126 +0xf5
created by database/sql.OpenDB
	/usr/local/go/src/database/sql/sql.go:740 +0x12a

goroutine 22 [select]:
github.com/robfig/cron/v3.(*Cron).run(0xc000142b40)
	/srv/app/pkg/mod/github.com/robfig/cron/v3@v3.0.1/cron.go:263 +0x545
created by github.com/robfig/cron/v3.(*Cron).Start
	/srv/app/pkg/mod/github.com/robfig/cron/v3@v3.0.1/cron.go:222 +0xa5

goroutine 23 [IO wait]:
internal/poll.runtime_pollWait(0x7f5a7998ec50, 0x72, 0x0)
	/usr/local/go/src/runtime/netpoll.go:222 +0x55
internal/poll.(*pollDesc).wait(0xc00058e018, 0x72, 0x0, 0x0, 0x13c0370)
	/usr/local/go/src/internal/poll/fd_poll_runtime.go:87 +0x45
internal/poll.(*pollDesc).waitRead(...)
	/usr/local/go/src/internal/poll/fd_poll_runtime.go:92
internal/poll.(*FD).Accept(0xc00058e000, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0)
	/usr/local/go/src/internal/poll/fd_unix.go:394 +0x1fc
net.(*netFD).accept(0xc00058e000, 0x7f5aa25f4fb8, 0x50, 0x50)
	/usr/local/go/src/net/fd_unix.go:172 +0x45
net.(*TCPListener).accept(0xc00038e120, 0x29e8d60800, 0x7f5a79972b48, 0xc000067cf0)
	/usr/local/go/src/net/tcpsock_posix.go:139 +0x32
net.(*TCPListener).AcceptTCP(0xc00038e120, 0xe993a020f3f74801, 0x0, 0x0)
	/usr/loca

2022-08-31T17:54:41.912671272Z: WEB 	▶ XX.XXX.XX.XXX  GET 500 /api/v1/info 524.497µs - Mozilla/5.0 (Windows NT 10.0; rv:104.0) Gecko/20100101 Firefox/104.0

I’m not sure how to debug this. Could you point me to the right direction, please?

Cheers.

The panic seems unrelated to the proxy config. I’d guess there’s something wrong with your openid config.

Running the frontend on a sub path is not really supported out of the box so you’d need to change the path and rebuild it yourself.