Skip to content

Proxy /explorer in the dev server to fix local CORS#5

Open
rawritude wants to merge 1 commit into
reflector-network:masterfrom
rawritude:pr-dev-proxy
Open

Proxy /explorer in the dev server to fix local CORS#5
rawritude wants to merge 1 commit into
reflector-network:masterfrom
rawritude:pr-dev-proxy

Conversation

@rawritude

Copy link
Copy Markdown

Developer-experience fix for local development.

The site is a client-rendered SPA whose price-display widgets fetch api.stellar.expert, which rejects cross-origin browser requests with a 403. As a result pnpm dev-server throws "Failed to fetch" runtime errors when the site is opened from localhost. On production the fetch is effectively same-origin, so this only affects local development.

This proxies /explorer to api.stellar.expert server-side in the dev server (changeOrigin, which drops the browser Origin and clears the 403), and selects a same-origin path in app.js when NODE_ENV === 'development'. Production API routing is unchanged.

The price-display widgets fetch api.stellar.expert, which rejects cross-origin
browser requests with a 403, so `pnpm dev-server` throws "Failed to fetch" from
localhost. Proxy /explorer to api.stellar.expert server-side in development
(changeOrigin) and select a same-origin path in app.js when NODE_ENV is
development. Production API routing is unchanged.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant