Forráskód Böngészése

Changed API endpoint

Pushkar Anand 4 éve
szülő
commit
bbe3286150

+ 2 - 0
.gitignore

@@ -35,3 +35,5 @@ yarn-error.log*
 
 out_functions
 out_publish
+
+.env

+ 7 - 2
netlify.toml

@@ -1,4 +1,9 @@
 [build]
   command   = "npm run build"
-  functions = "out_functions"
-  publish   = "out_publish"
+  publish   = "out_publish"
+
+[[headers]]
+  for = "/*"
+  [headers.values]
+    X-Frame-Options = "DENY"
+    X-XSS-Protection = "1; mode=block"

+ 2 - 0
public/robots.txt

@@ -0,0 +1,2 @@
+User-agent: *
+Disallow:

+ 1 - 0
src/components/Navbar.tsx

@@ -13,6 +13,7 @@ const Navbar = styled.div`
     margin-bottom: 10px;
     position: sticky;
     top: 0;
+    z-index: 1;
 `;
 
 export default Navbar;

+ 4 - 0
src/pages/_app.tsx

@@ -10,6 +10,7 @@ import { clearData, getData, LS_KEYS } from 'utils/storage/localStorage';
 import { useRouter } from 'next/router';
 import Container from 'components/Container';
 import PowerSettings from 'components/power_settings';
+import Head from 'next/head';
 
 const GlobalStyles = createGlobalStyle`
     html, body {
@@ -82,6 +83,9 @@ export default function App({ Component, pageProps }) {
 
     return (
         <>
+            <Head>
+                <title>ente.io | Privacy friendly alternative to Google Photos</title>
+            </Head>
             <GlobalStyles />
             <Navbar>
                 <FlexContainer>

+ 0 - 1
src/pages/_document.tsx

@@ -34,7 +34,6 @@ export default class MyDocument extends Document {
         return (
             <Html lang='en'>
                 <Head>
-                    <title>ente.io | Privacy friendly alternative to Google Photos</title>
                     <meta
                         name="description"
                         content="ente is a privacy friendly alternative to Google Photos that supports end-to-end encryption. Because memories are precious."

+ 3 - 1
src/pages/api/[...all].ts

@@ -6,8 +6,10 @@ export const config = {
     },
 };
 
+const API_ENDPOINT = process.env.NEXT_PUBLIC_ENTE_ENDPOINT || "http://api.staging.ente.io";
+
 export default createProxyMiddleware({
-    target: "http://api.staging.ente.io",
+    target: API_ENDPOINT,
     changeOrigin: true,
     pathRewrite: { '^/api': '/' },
 });

+ 2 - 1
src/pages/credentials/index.tsx

@@ -29,8 +29,9 @@ export default function Credentials() {
     const router = useRouter();
     const [keyAttributes, setKeyAttributes] = useState<keyAttributes>();
     const [loading, setLoading] = useState(false);
-
+    
     useEffect(() => {
+        router.prefetch('/gallery');
         const user = getData(LS_KEYS.USER);
         const keyAttributes = getData(LS_KEYS.KEY_ATTRIBUTES);
         const key = getKey(SESSION_KEYS.ENCRYPTION_KEY);

+ 2 - 1
src/pages/generate/index.tsx

@@ -31,8 +31,9 @@ export default function Generate() {
     const [token, setToken] = useState<string>();
     const router = useRouter();
     const key = getKey(SESSION_KEYS.ENCRYPTION_KEY);
-
+    
     useEffect(() => {
+        router.prefetch('/gallery');
         const user = getData(LS_KEYS.USER);
         if (!user?.token) {
             router.push("/");

+ 2 - 1
src/pages/index.tsx

@@ -18,8 +18,9 @@ interface formValues {
 export default function Home() {
     const [loading, setLoading] = useState(false);
     const router = useRouter();
-
+    
     useEffect(() => {
+        router.prefetch('/verify');
         const user = getData(LS_KEYS.USER);
         if (user?.email) {
             router.push('/verify');

+ 3 - 1
src/pages/verify/index.tsx

@@ -26,8 +26,10 @@ export default function Verify() {
     const [loading, setLoading] = useState(false);
     const [resend, setResend] = useState(0);
     const router = useRouter();
-
+    
     useEffect(() => {
+        router.prefetch('/credentials');
+        router.prefetch('/generate');
         const user = getData(LS_KEYS.USER);
         if (!user?.email) {
             router.push("/");

+ 7 - 3
src/services/userService.ts

@@ -1,16 +1,20 @@
 import HTTPService from './HTTPService';
 import { keyAttributes } from 'types';
 
+const dev = process.env.NODE_ENV === 'development';
+const API_ENDPOINT = process.env.NEXT_PUBLIC_ENTE_ENDPOINT || "https://api.staging.ente.io";
+const ENDPOINT = !dev ? API_ENDPOINT : '/api'
+
 export const getOtt = (email: string) => {
-    return HTTPService.get('/api/users/ott', { email })
+    return HTTPService.get(`${ENDPOINT}/users/ott`, { email })
 }
 
 export const verifyOtt = (email: string, ott: string) => {
-    return HTTPService.get('/api/users/credentials', { email, ott });
+    return HTTPService.get(`${ENDPOINT}/users/credentials`, { email, ott });
 }
 
 export const putKeyAttributes = (token: string, keyAttributes: keyAttributes) => {
-    return HTTPService.put('/api/users/key-attributes', keyAttributes, null, {
+    return HTTPService.put(`${ENDPOINT}/users/key-attributes`, keyAttributes, null, {
         'X-Auth-Token': token,
     });
 }