Skip to content

Commit 9a80fe3

Browse files
committed
docs: move CORS documentation under dashboard section
None of this applies to ports forwarded in other ways.
1 parent dfec519 commit 9a80fe3

File tree

1 file changed

+29
-23
lines changed

1 file changed

+29
-23
lines changed

docs/networking/port-forwarding.md

Lines changed: 29 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -84,31 +84,25 @@ Valid `share` values include `owner` - private to the user, `authenticated` - ac
8484

8585
![Port forwarding from an app in the UI](../images/coderapp-port-forward.png)
8686

87-
## SSH
87+
### Cross-origin resource sharing (CORS)
8888

89-
First, [configure SSH](../ides.md#ssh-configuration) on your
90-
local machine. Then, use `ssh` to forward like so:
89+
When forwarding via the dashboard, Coder automatically sets headers that allow
90+
requests between separately forwarded applications belonging to the same user.
9191

92-
```console
93-
ssh -L 8080:localhost:8000 coder.myworkspace
94-
```
92+
When forwarding through other methods the application itself will need to set
93+
its own CORS headers if they are being forwarded through different origins since
94+
Coder does not intercept these cases. See below for the required headers.
9595

96-
You can read more on SSH port forwarding [here](https://www.ssh.com/academy/ssh/tunneling/example).
97-
98-
## Cross-origin resource sharing (CORS)
99-
100-
Coder automatically sets headers that allow requests between separately
101-
forwarded applications belonging to the same user.
96+
#### Authentication
10297

103-
### Authentication
104-
105-
Since forwarded ports are private, cross-origin requests must include
106-
credentials (set `credentials: "include"` if using `fetch`) or the requests
107-
cannot be authenticated and you will see an error resembling the following:
98+
Since ports forwarded through the dashboard are private, cross-origin requests
99+
must include credentials (set `credentials: "include"` if using `fetch`) or the
100+
requests cannot be authenticated and you will see an error resembling the
101+
following:
108102

109103
> Access to fetch at 'https://dev.coder.com/api/v2/applications/auth-redirect' from origin 'https://8000--dev--user--apps.dev.coder.com' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.
110104
111-
### Headers
105+
#### Headers
112106

113107
Below is a list of the cross-origin headers Coder sets with example values:
114108

@@ -126,17 +120,18 @@ The allowed origin will be set to the origin provided by the browser if the
126120
users are identical. Credentials are allowed and the allowed methods and headers
127121
will echo whatever the request sends.
128122

129-
### Configuration
123+
#### Configuration
130124

131125
These cross-origin headers are not configurable by administrative settings.
132126

133127
Applications can set their own headers which will override the defaults but this
134-
will only apply to non-preflight requests. Preflight requests are never sent to
135-
applications and thus cannot be modified by them. Read more about the difference
136-
between simple requests and requests that trigger preflights
128+
will only apply to non-preflight requests. Preflight requests through the
129+
dashboard are never sent to applications and thus cannot be modified by
130+
them. Read more about the difference between simple requests and requests that
131+
trigger preflights
137132
[here](https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS#simple_requests).
138133

139-
### Allowed by default
134+
#### Allowed by default
140135

141136
<table class="tg">
142137
<thead>
@@ -199,3 +194,14 @@ between simple requests and requests that trigger preflights
199194
</table>
200195

201196
> '\*' means `credentials: "include"` is required
197+
198+
## SSH
199+
200+
First, [configure SSH](../ides.md#ssh-configuration) on your
201+
local machine. Then, use `ssh` to forward like so:
202+
203+
```console
204+
ssh -L 8080:localhost:8000 coder.myworkspace
205+
```
206+
207+
You can read more on SSH port forwarding [here](https://www.ssh.com/academy/ssh/tunneling/example).

0 commit comments

Comments
 (0)