https://github.com/iamelevich/pocketbase-plugin-proxy
This plugin allow proxify requests to other host. It can be useful if you want to use separate server as frontend but use one address for both frontend and backend.
https://github.com/iamelevich/pocketbase-plugin-proxy
pocketbase pocketbase-plugins proxy
Last synced: 2 months ago
JSON representation
This plugin allow proxify requests to other host. It can be useful if you want to use separate server as frontend but use one address for both frontend and backend.
- Host: GitHub
- URL: https://github.com/iamelevich/pocketbase-plugin-proxy
- Owner: iamelevich
- License: mit
- Created: 2023-03-19T22:32:42.000Z (about 3 years ago)
- Default Branch: master
- Last Pushed: 2026-03-06T01:23:54.000Z (2 months ago)
- Last Synced: 2026-03-06T05:29:38.370Z (2 months ago)
- Topics: pocketbase, pocketbase-plugins, proxy
- Language: Go
- Homepage:
- Size: 537 KB
- Stars: 21
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.md
Awesome Lists containing this project
- awesome-pocketbase - GitHub
- awesome-pocketbase - Proxy - Proxy requests to another other host. Can be useful when you want to use separate server as frontend (like Next.js), but serve everything with same port.  (Go Plugins)
README
[](https://github.com/iamelevich/pocketbase-plugin-proxy/actions/workflows/test.yml)
[](https://codecov.io/github/iamelevich/pocketbase-plugin-proxy)
* [Overview](#overview)
* [Requirements](#requirements)
* [Installation](#installation)
* [Example](#example)
* [pocketbase\_plugin\_proxy](#pocketbasepluginproxy)
* [Index](#index)
* [func DefaultSkipper](#func-defaultskipper)
* [type Options](#type-options)
* [type Plugin](#type-plugin)
* [func MustRegister](#func-mustregister)
* [func Register](#func-register)
* [func \(\*Plugin\) SetSkipper](#func-plugin-setskipper)
* [func \(\*Plugin\) Validate](#func-plugin-validate)
* [Contributing](#contributing)
* [Process](#process)
* [Development setup](#development-setup)
* [Testing](#testing)
* [Linting](#linting)
* [Docs update in README](#docs-update-in-readme)
# Overview
This plugin allow proxify requests to other host. It can be useful if you want to use separate server as frontend but use one address for both frontend and backend.
## Requirements
- [Pocketbase](https://github.com/pocketbase/pocketbase)
## Installation
```bash
go get github.com/iamelevich/pocketbase-plugin-proxy
```
## Example
You can check examples in [examples folder](/examples)
```go
package main
import (
"log"
proxyPlugin "github.com/iamelevich/pocketbase-plugin-proxy"
"github.com/pocketbase/pocketbase"
)
func main() {
app := pocketbase.New()
// Setup proxy plugin
proxyPlugin.MustRegister(app, &proxyPlugin.Options{
Enabled: true,
Url: "http://localhost:3000",
})
if err := app.Start(); err != nil {
log.Fatal(err)
}
}
```
# pocketbase\_plugin\_proxy
```go
import "github.com/iamelevich/pocketbase-plugin-proxy"
```
## Index
- [func DefaultSkipper\(c \*core.RequestEvent\) bool](<#DefaultSkipper>)
- [type Options](<#Options>)
- [type Plugin](<#Plugin>)
- [func MustRegister\(app core.App, options \*Options\) \*Plugin](<#MustRegister>)
- [func Register\(app core.App, options \*Options\) \(\*Plugin, error\)](<#Register>)
- [func \(p \*Plugin\) SetSkipper\(skipper Skipper\)](<#Plugin.SetSkipper>)
- [func \(p \*Plugin\) Validate\(\) error](<#Plugin.Validate>)
- [type Skipper](<#Skipper>)
```go
func DefaultSkipper(c *core.RequestEvent) bool
```
DefaultSkipper skip proxy middleware for requests, where path starts with /\_/ or /api/.
Options defines optional struct to customize the default plugin behavior.
```go
type Options struct {
// Enabled defines if proxy should be enabled.
Enabled bool
//Url to the target.
//
//Only http and https links are supported.
Url string
// Are proxy logs enabled?
ProxyLogsEnabled bool
}
```
```go
type Plugin struct {
// contains filtered or unexported fields
}
```
```go
func MustRegister(app core.App, options *Options) *Plugin
```
MustRegister is a helper function that registers plugin and panics if error occurred.
```go
func Register(app core.App, options *Options) (*Plugin, error)
```
Register registers plugin.
### func \(\*Plugin\) [SetSkipper]()
```go
func (p *Plugin) SetSkipper(skipper Skipper)
```
SetSkipper set skipper function that should return true if that route shouldn't be proxied.
If not set, the DefaultSkipper is used:
If set \- you should also control the middleware behavior for /\_/ and /api/ routes.
Example:
```
plugin := proxyPlugin.MustRegister(app, &proxyPlugin.Options{
Enabled: true,
Url: "http://localhost:3000",
})
plugin.SetSkipper(func(c *core.RequestEvent) bool {
return c.Request.URL.Path == "/my-super-secret-route"
})
```
### func \(\*Plugin\) [Validate]()
```go
func (p *Plugin) Validate() error
```
Validate plugin options. Return error if some option is invalid.
```go
type Skipper func(c *core.RequestEvent) bool
```
Generated by [gomarkdoc]()
# Contributing
This pocketbase plugin is free and open source project licensed under the [MIT License](LICENSE.md).
You are free to do whatever you want with it, even offering it as a paid service.
## Process
- Fork the repo
- Create a new branch
- Make your changes
- Create a pull request
- Wait for review
- Make changes if needed
- Merge
- Celebrate :)
## Development setup
- Install [mise](https://mise.jdx.dev/installing-mise.html) and run `mise install`.
- Setup `prek` hooks with `prek install -t commit-msg -t pre-commit`
## Testing
- Run `mise run test` to run tests
- Run `mise run test-report` to run tests and get coverage report in `./coverage.html`
## Linting
- Run `mise run lint` to run linters
## Docs update in README
- Run `mise run docs` to update docs in README (it will also install [gomarkdoc](https://github.com/princjef/gomarkdoc))