DioxusLabs/dioxus · error · syn::Error

keyword argument repeated: `endpoint`

Error message

keyword argument repeated: `endpoint`

What it means

`endpoint` sets a custom URL/endpoint for a `#[server]` function and may appear at most once. A second `endpoint = ...` is rejected by the keyword parser (packages/fullstack-macro/src/lib.rs:1580-1586).

Source

Thrown at packages/fullstack-macro/src/lib.rs:1582

                    } else if key == "prefix" {
                        if prefix.is_some() {
                            return Err(syn::Error::new(
                                key.span(),
                                "keyword argument repeated: `prefix`",
                            ));
                        }
                        prefix = Some(stream.parse()?);
                    } else if key == "encoding" {
                        if encoding.is_some() {
                            return Err(syn::Error::new(
                                key.span(),
                                "keyword argument repeated: `encoding`",
                            ));
                        }
                        encoding = Some(stream.parse()?);
                    } else if key == "endpoint" {
                        if fn_path.is_some() {
                            return Err(syn::Error::new(
                                key.span(),
                                "keyword argument repeated: `endpoint`",
                            ));
                        }
                        fn_path = Some(stream.parse()?);
                    } else if key == "input" {
                        if encoding.is_some() {
                            return Err(syn::Error::new(
                                key.span(),
                                "`encoding` and `input` should not both be \
                                 specified",
                            ));
                        } else if input.is_some() {
                            return Err(syn::Error::new(
                                key.span(),
                                "keyword argument repeated: `input`",
                            ));
                        }

View on GitHub (pinned to 393d190a80)

Solutions

  1. Keep exactly one `endpoint = ...` value (use a `const` string if you switch environments).
  2. For per-environment endpoints, prefer a runtime `server_fn::client!()`/URL override or Cargo feature/cfg instead of editing the attribute per build.
  3. After scaffolding or merges, scan the attribute for repeated keys.

Example fix

// before
#[server(endpoint = "http://localhost:8080/api", endpoint = "https://prod.example.com/api")]
async fn load() -> Data { ... }

// after
const ENDPOINT: &str = if cfg!(debug_assertions) { "http://localhost:8080/api" } else { "https://prod.example.com/api" };
#[server(endpoint = ENDPOINT)]
async fn load() -> Data { ... }
Defensive patterns

Strategy: validation

Validate before calling

# Reuse the duplicate-key checker from index 93; endpoint is in its key list.

Prevention

When it happens

Trigger: `#[server(endpoint = "https://a.dev/api", endpoint = "https://b.dev/api")]`; environment-driven copy-paste where a dev and a prod endpoint both got left in; combining `prefix`-style configuration with an extra `endpoint` override and duplicating it.

Common situations: Switching deployed environments by editing the attribute and forgetting the old value; merge conflicts; scaffolding scripts that append configuration instead of replacing.

Related errors


AI-assisted analysis of DioxusLabs/dioxus@393d190a80 (2026-08-16). Data as JSON: /api/errors/8e28ffa81415f36c. Report an issue: GitHub.