Skip to content
Snippets Groups Projects
Commit eabadf09 authored by Jonas Braathen's avatar Jonas Braathen
Browse files

Make all URLs relative. Move /oidc and /admin endpoints up from /api and proxy...

Make all URLs relative. Move /oidc and /admin endpoints up from /api and proxy them during development.
parent dd0cb18d
No related branches found
No related tags found
1 merge request!84Greg 51 deploy frontend
Pipeline #95810 passed
......@@ -30,7 +30,7 @@ export const Debug = () => {
if (!didContactApi) {
setDidContactApi(true)
fetch('http://localhost:3000/api/health/')
fetch('/api/health/')
.then((res) => res.text())
.then((result) => {
if (result === 'OK') {
......
......@@ -9,9 +9,7 @@ type OuData = {
function useOus(): OuData[] {
const [ous, setOus] = useState<OuData[]>([])
const getOptions = async () => {
const response = await fetch(
'http://localhost:3000/api/ui/v1/ous/?format=json'
)
const response = await fetch('/api/ui/v1/ous/?format=json')
if (response.ok) {
const ousJson = await response.json()
setOus(ousJson.ous)
......
......@@ -20,7 +20,7 @@ export default function LoginPage() {
<Container maxWidth="sm">
<h2>{t('header')}</h2>
<StyledParagraph>{t('description')}</StyledParagraph>
<HrefButton to="/api/oidc/authenticate">{t('login')}</HrefButton>
<HrefButton to="/oidc/authenticate/">{t('login')}</HrefButton>
</Container>
</StyledWrapper>
)
......
......@@ -50,7 +50,7 @@ export default function App() {
<ProtectedRoute path='/sponsor'>
<Sponsor />
</ProtectedRoute>
<Route path='register'>
<Route path='/register'>
<Register />
</Route>
<Route>
......
......@@ -35,7 +35,7 @@ const StepSummary = forwardRef((props: StepSummaryProperties, ref: Ref<PersonFor
email: data.email,
}
console.log('submitting', JSON.stringify(payload))
fetch('http://localhost:3000/api/ui/v1/register/', postJsonOpts(payload))
fetch('/api/ui/v1/register/', postJsonOpts(payload))
.then((res) => res.text())
.then((result) => {
console.log('result', result)
......
......@@ -151,9 +151,7 @@ function FrontPage() {
const [t] = useTranslation(['common'])
const fetchGuestsInfo = async () => {
const response = await fetch(
'http://localhost:3000/api/ui/v1/persons/?format=json'
)
const response = await fetch('/api/ui/v1/persons/?format=json')
const jsonResponse = await response.json()
if (response.ok) {
const roles = await jsonResponse.roles
......
......@@ -2,7 +2,13 @@ const { createProxyMiddleware } = require('http-proxy-middleware')
module.exports = (app) => {
app.use(
'/api',
[
'/admin*', // Django admin
'/staticfiles*', // Django static files
'/api*', // API
'/schema*', // API schema
'/oidc*', // OpenID connect login endpoint
],
createProxyMiddleware({
target: 'http://localhost:8000',
changeOrigin: true,
......
......@@ -22,8 +22,8 @@ from gregui import urls as ui_urls
admin.autodiscover()
urlpatterns = [
path("api/admin/", admin.site.urls),
path("admin/", admin.site.urls),
path("", include(greg_urls.urlpatterns)),
path("", include(ui_urls.urlpatterns)),
path("api/oidc/", include("mozilla_django_oidc.urls")),
path("oidc/", include("mozilla_django_oidc.urls")),
]
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment