Metadata improvements
This commit is contained in:
parent
7bd54359e6
commit
a3b21edf0c
|
@ -1,11 +1,8 @@
|
||||||
import { navigate } from "gatsby";
|
import { navigate } from "gatsby";
|
||||||
import { StatusCodes } from "http-status-codes";
|
import { StatusCodes } from "http-status-codes";
|
||||||
|
|
||||||
// TODO: portal-aware URL
|
|
||||||
const baseUrl = process.env.NODE_ENV !== "production" ? "/api" : "https://account.skynetpro.net/api";
|
|
||||||
|
|
||||||
const redirectUnauthenticated = (key) =>
|
const redirectUnauthenticated = (key) =>
|
||||||
fetch(`${baseUrl}/${key}`).then((response) => {
|
fetch(`/api/${key}`).then((response) => {
|
||||||
if (response.status === StatusCodes.UNAUTHORIZED) {
|
if (response.status === StatusCodes.UNAUTHORIZED) {
|
||||||
navigate(`/auth/login?return_to=${encodeURIComponent(window.location.href)}`);
|
navigate(`/auth/login?return_to=${encodeURIComponent(window.location.href)}`);
|
||||||
return null;
|
return null;
|
||||||
|
@ -15,7 +12,7 @@ const redirectUnauthenticated = (key) =>
|
||||||
});
|
});
|
||||||
|
|
||||||
const redirectAuthenticated = (key) =>
|
const redirectAuthenticated = (key) =>
|
||||||
fetch(`${baseUrl}/${key}`).then(async (response) => {
|
fetch(`/api/${key}`).then(async (response) => {
|
||||||
if (response.ok) {
|
if (response.ok) {
|
||||||
await navigate("/");
|
await navigate("/");
|
||||||
return response.json();
|
return response.json();
|
||||||
|
@ -27,7 +24,7 @@ const redirectAuthenticated = (key) =>
|
||||||
});
|
});
|
||||||
|
|
||||||
export const allUsers = {
|
export const allUsers = {
|
||||||
fetcher: (key) => fetch(`${baseUrl}/${key}`).then((response) => response.json()),
|
fetcher: (key) => fetch(`/api/${key}`).then((response) => response.json()),
|
||||||
};
|
};
|
||||||
|
|
||||||
export const authenticatedOnly = {
|
export const authenticatedOnly = {
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
import { SkynetClient } from "skynet-js";
|
import { SkynetClient } from "skynet-js";
|
||||||
|
|
||||||
export default new SkynetClient("https://skynetpro.net"); // TODO: proper API url
|
export default new SkynetClient(`https://${process.env.GATSBY_PORTAL_DOMAIN}`);
|
||||||
|
|
Reference in New Issue