Skip to content
Open
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
12 changes: 11 additions & 1 deletion plugin/Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,23 @@ tasks:
cmds:
- cmd: ./build/deweb-plugin

build:
build-frontend:
dir: home
cmds:
- cmd: npm run build

build-backend:
cmds:
- task: build:internal
vars:
APP_NAME: plugin
BIN_DIR: build

build:
cmds:
- task: build-frontend
- task: build-backend

build:internal:
build:
desc: Internal build task
Expand Down
117 changes: 117 additions & 0 deletions plugin/api/models/network_info_item.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

64 changes: 15 additions & 49 deletions plugin/api/models/server_status.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 13 additions & 4 deletions plugin/api/models/settings.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 17 additions & 8 deletions plugin/api/pluginAPI-V0.yml
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,22 @@ definitions:
required:
- code
- message

NetworkInfoItem:
type: object
description: Detailed network information
properties:
name:
type: string
url:
type: string
chainId:
type: integer
version:
type: string
status:
type: string
enum: [up, down]

ServerStatus:
type: object
Expand All @@ -114,14 +130,7 @@ definitions:
description: Error message if server failed to start or is in error state
network:
type: object
properties:
network:
type: string
version:
type: string
chainID:
type: integer
format: uint64
$ref: "#/definitions/NetworkInfoItem"

Settings:
type: object
Expand Down
10 changes: 9 additions & 1 deletion plugin/api/restapi/configure_deweb_plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import (
"github.com/go-openapi/runtime"
"github.com/go-openapi/runtime/middleware"
"github.com/massalabs/deweb-plugin/api/restapi/operations"
dewebmiddleware "github.com/massalabs/deweb-plugin/int/api/middleware"
"github.com/rs/cors"
)

//go:generate swagger generate server --target ../../api --name DewebPlugin --spec ../pluginAPI-V0.yml --principal interface{} --exclude-main
Expand Down Expand Up @@ -104,5 +106,11 @@ func setupMiddlewares(handler http.Handler) http.Handler {
// The middleware configuration happens before anything, this middleware also applies to serving the swagger.json document.
// So this is a good place to plug in a panic handling middleware, logging and metrics.
func setupGlobalMiddleware(handler http.Handler) http.Handler {
return handler
handleCORS := cors.New(cors.Options{
AllowedMethods: []string{http.MethodGet, http.MethodPut},
AllowedOrigins: dewebmiddleware.AllowedDomainsList(),
}).Handler

// Middleware chain: CORS → WebAppMiddleware → DomainRestrictionMiddleware → API handlers
return handleCORS(dewebmiddleware.WebAppMiddleware(dewebmiddleware.DomainRestrictionMiddleware(handler)))
Comment on lines +109 to +115
Copy link

Copilot AI Jan 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The CORS middleware is configured with AllowedOrigins but uses a whitelist approach via DomainRestrictionMiddleware. These two mechanisms overlap and could lead to confusion. The CORS AllowedOrigins setting will allow preflight requests from these domains, but then DomainRestrictionMiddleware checks the origin again. Consider consolidating this logic or clearly documenting why both are necessary.

Copilot uses AI. Check for mistakes.
}
Loading
Loading