Skip to content

Commit

Permalink
change backend route
Browse files Browse the repository at this point in the history
  • Loading branch information
kenahrens committed Apr 6, 2024
1 parent 1da6914 commit 0697af7
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 1 deletion.
1 change: 1 addition & 0 deletions ui/.env_example
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
VITE_JSON_SERVER_URL=http://localhost:8080/api
35 changes: 35 additions & 0 deletions ui/nginx-default.conf
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,39 @@ server {
root /usr/share/nginx/html;
try_files $uri /index.html;
}

location /api/ {
if ($request_method = 'OPTIONS') {
add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
#
# Custom headers and headers various browsers *should* be OK with but aren't
#
add_header 'Access-Control-Allow-Headers' 'DNT,Authorization,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range';
#
# Tell client that this pre-flight info is valid for 20 days
#
add_header 'Access-Control-Max-Age' 1728000;
add_header 'Content-Type' 'text/plain; charset=utf-8';
add_header 'Content-Length' 0;
return 204;
}
if ($request_method = 'POST') {
add_header 'Access-Control-Allow-Origin' '*' always;
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS' always;
add_header 'Access-Control-Allow-Headers' 'DNT,Authorization,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range' always;
add_header 'Access-Control-Expose-Headers' 'Content-Length,Content-Range' always;
}
if ($request_method = 'GET') {
add_header 'Access-Control-Allow-Origin' '*' always;
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS' always;
add_header 'Access-Control-Allow-Headers' 'DNT,Authorization,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range' always;
add_header 'Access-Control-Expose-Headers' 'Content-Length,Content-Range' always;
}
proxy_pass http://api.default.svc.cluster.local:80/;
proxy_http_version 1.1;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-NginX-Proxy true;
}
}
3 changes: 2 additions & 1 deletion ui/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ import {
import { PoemList, PoemShow, PoemCreate } from './routes/poems'
import { ChatList, ChatShow, ChatCreate } from './routes/chats'
import { dataProvider } from "./dataProvider";
import authProvider from "./authProvider";

export const App = () => (
<Admin dataProvider={dataProvider} >
<Admin dataProvider={dataProvider} authProvider={authProvider} >
<Resource name="poems" list={PoemList} show={PoemShow} create={PoemCreate} />
<Resource name="chats" list={ChatList} show={ChatShow} create={ChatCreate} />
</Admin>
Expand Down

0 comments on commit 0697af7

Please sign in to comment.