Skip to content

Commit

Permalink
add next config for proxying api reqs
Browse files Browse the repository at this point in the history
  • Loading branch information
ob6160 committed Jul 26, 2021
1 parent 50f7661 commit 3e932f3
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 8 deletions.
9 changes: 8 additions & 1 deletion next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,12 @@ module.exports = {
});
return config;
},

async rewrites() {
return [
{
source: '/api/:path*',
destination: 'http://localhost:4000/:path*' // Proxy to Backend
}
]
}
}
13 changes: 7 additions & 6 deletions src/components/LooMap/LooMap.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { useEffect } from 'react';
import PropTypes from 'prop-types';
import Router from 'next/router';
import Router, { useRouter } from 'next/router';
import { css } from '@emotion/react';
import { Map, TileLayer, ZoomControl } from 'react-leaflet';
import 'focus-visible';
Expand Down Expand Up @@ -86,6 +86,7 @@ const LooMap = ({
});
};

const router = useRouter();


const memoizedMarkers = React.useMemo(
Expand All @@ -105,18 +106,18 @@ const LooMap = ({
label={toilet.name || 'Unnamed toilet'}
onClick={() => {
if (!staticMap) {
Router.push(`/loos/${toilet.id}`);
router.push(`/loos/${toilet.id}`, undefined, {shallow: true});
}
}}
onKeyDown={(event: { originalEvent: { keyCode: number; }; }) => {
if (!staticMap && event.originalEvent.keyCode === KEY_ENTER) {
Router.push(`/loos/${toilet.id}`);
router.push(`/loos/${toilet.id}`, undefined, {shallow: true});
}
}}
keyboard={false}
/>
)),
[loos, staticMap, Router.push]
[loos, staticMap, router.push]
);

const keyboardSelectionHandler = React.useCallback(
Expand All @@ -129,9 +130,9 @@ const LooMap = ({

setAnnouncement(`${toilet.name || 'Unnamed toilet'} selected`);

Router.push(`/loos/${toilet.id}`);
router.push(`/loos/${toilet.id}`, undefined, {shallow: true});
},
[intersectingToilets, Router.push]
[intersectingToilets, router.push]
);

React.useEffect(() => {
Expand Down
2 changes: 1 addition & 1 deletion src/pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ const Explorer = lazy(() =>
import(/*webpackChunkName: 'explorer'*/ '../explorer')
);
const AddPage = lazy(() =>
import(/*webpackChunkName: 'add'*/ './loos/add')
import(/*webpackChunkName: 'add'*/ './loose/add')
);
const EditPage = lazy(() =>
import(/*webpackChunkName: 'edit'*/ './EditPage')
Expand Down
File renamed without changes.

0 comments on commit 3e932f3

Please sign in to comment.