Skip to content

Commit

Permalink
feat: Configuring the Proxy (#200)
Browse files Browse the repository at this point in the history
Added instructions for configuring the service worker proxy
  • Loading branch information
CompuIves authored Oct 27, 2023
1 parent bee00e2 commit cb37f3c
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion packages/projects-docs/pages/learn/repositories/preview.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,13 @@ This will often make hot module reloading work out of the box for frameworks lik

### Service Worker Proxy

If possible, we try to install a service worker in the preview that will proxy requests to [`localhost:3000`](http://localhost:3000) to the corresponding dev URL. The service worker only proxies URLs that are going to localhost, or URLs that go to e.g. `https://3000-:id.preview.csb.app:4000`.
If possible, we try to install a service worker in the preview that will proxy requests to [`localhost:3000`](http://localhost:3000) to the corresponding dev URL. The service worker only proxies URLs that are going to localhost, or URLs that go to e.g. `https://3000-:id.preview.csb.app:4000`.

#### Configuring the Proxy

The service worker proxy is enabled by default, but you can turn it off in two ways:

1. Configure the dev server to respond with the `x-csb-no-sw-proxy` header when sending HTML responses (any value is possible)
2. Or, set `csbLocalProxyEnabled` to `false` in the localStorage: `localStorage.setItem('csbLocalProxyEnabled', 'false');`.

When the `x-csb-no-sw-proxy` header is set, we automatically add `localStorage.setItem('csbLocalProxyEnabled', 'false');` to the returned HTML from the dev server.

1 comment on commit cb37f3c

@vercel
Copy link

@vercel vercel bot commented on cb37f3c Oct 27, 2023

Choose a reason for hiding this comment

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

Please sign in to comment.