Skip to content

Commit 91d25cc

Browse files
authored
Use /api instead of dedicated API subdomain (#54)
1 parent 287b346 commit 91d25cc

File tree

4 files changed

+26
-9
lines changed

4 files changed

+26
-9
lines changed

config/nginx.conf

+21-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
## csss-site-frontend nginx configuration file
22

3+
upstream backend {
4+
server unix:/var/www/gunicorn.sock fail_timeout=0;
5+
}
6+
37
server {
48
server_name new.sfucsss.org;
59
listen 443 ssl;
@@ -12,20 +16,34 @@ server {
1216
include /etc/letsencrypt/options-ssl-nginx.conf;
1317
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;
1418

19+
# proxy csss-site-backend
20+
location /api/ {
21+
# rewrite location to exclude leading /api
22+
rewrite ^/api/(.*)$ /$1 break;
23+
24+
# proxy request through the backend
25+
proxy_pass http://backend;
26+
proxy_set_header Host $host;
27+
proxy_set_header X-Real-IP $remote_addr;
28+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
29+
proxy_set_header X-Forwarded-Proto $scheme;
30+
}
31+
1532
# redirects old 2024 mountain madness requests to the new URL
1633
location ~ ^/events/2024/mm(/|/index.html)?$ {
1734
return 301 /mountain_madness/2024/index.html;
1835
}
19-
20-
location = / {
36+
37+
# any other matching path
38+
location / {
2139
try_files $uri $uri/ $uri/index.html =404;
2240
}
2341
}
2442

2543
server {
2644
server_name new.sfucsss.org;
2745
listen 80;
28-
46+
2947
if ($host = new.sfucsss.org) {
3048
return 301 https://$host$request_uri;
3149
}

src/_shared/js/helpers.js

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const CSSS_API = 'https://api.sfucsss.org';
1+
const CSSS_API = 'https://new.sfucsss.org/api';
22

33
/**
44
* Checks if a media query matches.
@@ -89,9 +89,8 @@ export function casLogin(next) {
8989
/** get information about the currently logged in user */
9090
export async function casGetUser() {
9191
try {
92-
const response = await fetch(`${CSSS_API}/auth/check`, {
93-
method: 'GET',
94-
credentials: 'include' // cookies
92+
const response = await fetch('/api/auth/check', {
93+
method: 'GET'
9594
});
9695

9796
if (!response.ok) {

src/_shared/react/VSCode/Page.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ export const Page = (props) => {
7474
<div
7575
className="bg-zinc-950 border-t border-zinc-800 flex flex-row"
7676
style={{
77-
'grid-area': 'bottom-bar'
77+
gridArea: 'bottom-bar'
7878
}}
7979
>
8080
<p

src/main/pages/Home.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ export const Home = () => {
103103
src="/static/files/main/president.jpg"
104104
alt="President Portrait"
105105
className="w-64 h-80 object-cover rounded-lg float-left mr-6 mb-4"
106-
style={{ 'overflow-clip-margin': 'unset' }}
106+
style={{ overflowClipMargin: 'unset' }}
107107
/>
108108
<p
109109
className="text-lg sm:text-xl md:text-2xl leading-relaxed text-left"

0 commit comments

Comments
 (0)