Skip to content

Commit a7ef1c3

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

File tree

1 file changed

+21
-17
lines changed

1 file changed

+21
-17
lines changed

docs/networking/port-forwarding.md

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -84,31 +84,24 @@ 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.
102-
103-
### Authentication
96+
#### Authentication
10497

10598
Since forwarded ports are private, cross-origin requests must include
10699
credentials (set `credentials: "include"` if using `fetch`) or the requests
107100
cannot be authenticated and you will see an error resembling the following:
108101

109102
> 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.
110103
111-
### Headers
104+
#### Headers
112105

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

@@ -126,7 +119,7 @@ The allowed origin will be set to the origin provided by the browser if the
126119
users are identical. Credentials are allowed and the allowed methods and headers
127120
will echo whatever the request sends.
128121

129-
### Configuration
122+
#### Configuration
130123

131124
These cross-origin headers are not configurable by administrative settings.
132125

@@ -136,7 +129,7 @@ applications and thus cannot be modified by them. Read more about the difference
136129
between simple requests and requests that trigger preflights
137130
[here](https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS#simple_requests).
138131

139-
### Allowed by default
132+
#### Allowed by default
140133

141134
<table class="tg">
142135
<thead>
@@ -199,3 +192,14 @@ between simple requests and requests that trigger preflights
199192
</table>
200193

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

0 commit comments

Comments
 (0)