Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add subpath #120

Merged
merged 6 commits into from
Sep 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Usage of Falcosidekick-UI:
-d boolean
Disable authentication (environment "FALCOSIDEKICK_UI_DISABLEAUTH")
-l string
Log level: "debug", "info", "warning", "error" (default "info", environment "FALCOSIDEKICK_UI_LOGLEVEL")
Log level: "debug", "info", "warning", "error" (default "info", environment "FALCOSIDEKICK_UI_LOGLEVEL")
-p int
Listen Port (default "2802", environment "FALCOSIDEKICK_UI_PORT")
-r string
Expand All @@ -38,7 +38,7 @@ Usage of Falcosidekick-UI:
-v boolean
Display version
-w string
Redis password (default "", environment "FALCOSIDEKICK_REDIS_PASSWORD")
Redis password (default "", environment "FALCOSIDEKICK_UI_REDIS_PASSWORD")
-x boolean
Allow CORS for development (environment "FALCOSIDEKICK_UI_DEV")
```
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/http.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import store from './store';
const production = process.env.NODE_ENV === 'production';

const api = axios.create({
baseURL: `${production ? `//${window.location.host}` : process.env.VUE_APP_API}/api/v1`,
baseURL: `${production ? `//${window.location.host}${window.location.pathname}` : process.env.VUE_APP_API}api/v1`,
headers: {
'Content-type': 'application/json',
'Access-Control-Allow-Origin': '*',
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/router/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ const routes = [
];

const router = new VueRouter({
mode: 'history',
mode: 'hash',
base: process.env.BASE_URL,
routes,
});
Expand Down
3 changes: 3 additions & 0 deletions frontend/vue.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
publicPath: './',
};
38 changes: 15 additions & 23 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,26 +39,26 @@ func init() {
disableauth := utils.GetBoolFlagOrEnvParam("d", "FALCOSIDEKICK_UI_DISABLEAUTH", false, "Disable authentication")

flag.Usage = func() {
help := `Usage of Falcosidekick-UI:
help := `Usage of Falcosidekick-UI:
-a string
Listen Address (default "0.0.0.0", environment "FALCOSIDEKICK_UI_ADDR")
-d boolean
Disable authentication (environment "FALCOSIDEKICK_UI_DISABLEAUTH")
-l string
Log level: "debug", "info", "warning", "error" (default "info", environment "FALCOSIDEKICK_UI_LOGLEVEL")
-l string
Log level: "debug", "info", "warning", "error" (default "info", environment "FALCOSIDEKICK_UI_LOGLEVEL")
-p int
Listen Port (default "2802", environment "FALCOSIDEKICK_UI_PORT")
-r string
Redis server address (default "localhost:6379", environment "FALCOSIDEKICK_UI_REDIS_URL")
-t string
TTL for keys, the format is X<unit>,
with unit (s, m, h, d, W, M, y)" (default "0", environment "FALCOSIDEKICK_UI_TTL")
-u string
-u string
User in format <login>:<password> (default "admin:admin", environment "FALCOSIDEKICK_UI_USER")
-v boolean
Display version
-w string
Redis password (default "", environment "FALCOSIDEKICK_REDIS_PASSWORD")
-w string
Redis password (default "", environment "FALCOSIDEKICK_UI_REDIS_PASSWORD")
-x boolean
Allow CORS for development (environment "FALCOSIDEKICK_UI_DEV")
`
Expand Down Expand Up @@ -117,39 +117,31 @@ func init() {
func main() {
e := echo.New()
v := &CustomValidator{validator: validator.New()}
c := configuration.GetConfiguration()
config := configuration.GetConfiguration()

e.Validator = v
e.HideBanner = true
e.HidePort = true

if c.DevMode {
if config.DevMode {
utils.WriteLog("warning", "DEV mode enabled")
e.Use(middleware.CORS())
}
if c.DisableAuth {
if config.DisableAuth {
utils.WriteLog("warning", "Auhentication disabled")
e.Use(middleware.CORS())
}
utils.WriteLog("info", fmt.Sprintf("Falcosidekick UI is listening on %v:%v", c.ListenAddress, c.ListenPort))
utils.WriteLog("info", fmt.Sprintf("log level is %v", c.LogLevel))

utils.WriteLog("info", fmt.Sprintf("Falcosidekick UI is listening on %v:%v", config.ListenAddress, config.ListenPort))
utils.WriteLog("info", fmt.Sprintf("Log level is %v", config.LogLevel))

e.GET("/docs/*", echoSwagger.WrapHandler)
e.GET("/docs", func(c echo.Context) error {
if err := c.Redirect(http.StatusPermanentRedirect, "docs/"); err != nil {
return err
}
return nil
return c.Redirect(http.StatusPermanentRedirect, "docs/")
})
e.Static("/*", "frontend/dist").Name = "webui-home"
e.Static("/dashboard", "frontend/dist").Name = "webui-dashboard"
e.Static("/events", "frontend/dist").Name = "webui-events"
e.Static("/info", "frontend/dist").Name = "webui-info"
e.Static("/login", "frontend/dist").Name = "webui-login"
e.POST("/", api.AddEvent).Name = "add-event" // for compatibility with old Falcosidekicks

// e.Use(middleware.BodyDump(func(c echo.Context, reqBody, resBody []byte) {
// }))
e.POST("/", api.AddEvent).Name = "add-event" // for compatibility with old Falcosidekicks

apiRoute := e.Group("/api/v1")
apiRoute.Use(middleware.BasicAuthWithConfig(middleware.BasicAuthConfig{
Expand Down Expand Up @@ -192,7 +184,7 @@ func main() {
eventsRoute.GET("/count/:groupby", api.CountByEvent).Name = "count-events-by"
eventsRoute.GET("/search", api.Search).Name = "search-keys"

e.Logger.Fatal(e.Start(fmt.Sprintf("%v:%v", c.ListenAddress, c.ListenPort)))
e.Logger.Fatal(e.Start(fmt.Sprintf("%v:%v", config.ListenAddress, config.ListenPort)))
}

func (cv *CustomValidator) Validate(i interface{}) error {
Expand Down
Loading