kataras / kataras/iris

SPA routing

Open
#1,653 13 comments 0 reactions 0 assignees View on GitHub
🤔 type:question
Dominant language
Go
Stars
25.6k
Forks
2.4k
PR merge metrics
No merged PRs in 30d

Description

I'm setting up an SPA application using Vue Router with the history mode, so I'd like to redirect all non-static-file requests to the static index.html file served by `app.HandleDir("/", "./frontend/dist")`.

I've tried the following:

```go
app.Get("/*", func(ctx iris.Context) {
ctx.View("index.html")
})
```

But this overrides the static file routes and other API routes, so what's the way to handle all other routes?

Contributor guide

Open the contributing guide

Research direction

Start by reading the routing behavior around app.HandleDir("/", "./frontend/dist"), app.Get("/*", ...), and ctx.View("index.html"). Determine how a fallback for non-static-file requests can coexist with static file and API routes; done means SPA history-mode URLs serve index.html without overriding those existing routes.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
backend, web-dev
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.