diff --git a/package.json b/package.json index f9c343e..2dd781e 100755 --- a/package.json +++ b/package.json @@ -12,6 +12,7 @@ "@nuxtjs/axios": "^5.13.6", "@nuxtjs/composition-api": "0.23.4", "@nuxtjs/dotenv": "^1.4.1", + "@nuxtjs/proxy": "^2.1.0", "@nuxtjs/redirect-module": "^0.3.1", "@nuxtjs/robots": "^2.5.0", "@nuxtjs/sentry": "^5.1.0", diff --git a/settings/Arch.ts b/settings/Arch.ts index 7f1d3d6..0d57738 100755 --- a/settings/Arch.ts +++ b/settings/Arch.ts @@ -34,4 +34,11 @@ const buildDir = 'build' const ssr = true -export default { srcDir, dir, build, pageTransition, target, server, buildDir, components, ssr } +const proxy = { + '/api': { + target: "https://api.arthurdanjou.fr", + pathRewrite: { "^/api": "" } + } +} + +export default { srcDir, dir, build, pageTransition, target, server, buildDir, components, ssr, proxy } diff --git a/settings/Modules.ts b/settings/Modules.ts index 5954e53..99032ab 100755 --- a/settings/Modules.ts +++ b/settings/Modules.ts @@ -1,11 +1,8 @@ import {NuxtOptionsModule} from "@nuxt/types/config/module"; const axios = { - baseURL: 'https://api.arthurdanjou.fr', - headers: { - 'Content-Type': 'application/json', - 'Accept': '*/*' - }, + proxy: true, + credentials: true } const i18n = { @@ -86,10 +83,7 @@ const env = { } const sentry = { - dsn: process.env.SENTRY_DSN, - config: { - - } + dsn: process.env.SENTRY_DSN } export default [ diff --git a/src/components/Footer.vue b/src/components/Footer.vue index 5642520..fd9d94a 100755 --- a/src/components/Footer.vue +++ b/src/components/Footer.vue @@ -19,9 +19,9 @@ {{ $t('header.env') }}, - + {{ $t('header.contact') }}, diff --git a/src/components/GuestBookForm.vue b/src/components/GuestBookForm.vue index a329ec2..ad491e4 100644 --- a/src/components/GuestBookForm.vue +++ b/src/components/GuestBookForm.vue @@ -2,27 +2,15 @@

{{ $t('guestbook.signin') }}

{{ $t('guestbook.share') }}

-
-
- - -
-
-
- {{ $t('guestbook.form.error') }} -
+
+
+ +
+
+ +
+
+
@@ -34,13 +22,13 @@ v-model="form.message" class="pl-4 pr-32 py-2 mt-1 block w-full border-gray-300 rounded-md bg-white dark:bg-gray-800 text-gray-900 dark:text-gray-100" > - +
@@ -66,10 +54,11 @@ export default defineComponent({ setup() { const { $axios, $sentry, app } = useContext() - const email = ref('') - const login = async () => { - const response = await $axios.post('/guestbook/login', { - email: email.value + const login = async (driver: 'github' | 'google' | 'twitter') => { + const response = await $axios.get(`/api/auth/${driver}`, { + headers: { + 'Access-Control-Allow-Origin': '*' + } }) if (response.status === 200) { await hasAlreadySignMessage(response.data.user.id) @@ -84,7 +73,7 @@ export default defineComponent({ const form = ref({} as GuestbookForm) const handleForm = async () => { - const response = await $axios.post('/guestbook', { + const response = await $axios.post('/api/guestbook', { message: form.value.message }, { headers: { @@ -131,8 +120,7 @@ export default defineComponent({ error, alreadySent, handleForm, - hasAlreadySignMessage, - email + hasAlreadySignMessage } } }) diff --git a/src/layouts/error.vue b/src/layouts/error.vue index de99e2c..01e7977 100755 --- a/src/layouts/error.vue +++ b/src/layouts/error.vue @@ -25,7 +25,7 @@
-
+
diff --git a/src/locales/en-EN.ts b/src/locales/en-EN.ts index c51b946..60c050c 100755 --- a/src/locales/en-EN.ts +++ b/src/locales/en-EN.ts @@ -198,11 +198,7 @@ export default { placeholder: 'Your message...', sign: 'Sign', error: 'Error while sending your message ❌', - success: 'Thank you for your message 😉', - form: { - placeholder: 'tim@apple.com', - error: 'Error while logging ❌', - } + success: 'Thank you for your message 😉' }, newsletter: { diff --git a/src/locales/fr-FR.ts b/src/locales/fr-FR.ts index 3f8c798..39fdca5 100755 --- a/src/locales/fr-FR.ts +++ b/src/locales/fr-FR.ts @@ -198,11 +198,7 @@ export default { placeholder: 'Votre message...', sign: 'Signer', error: "Erreur lors de l'envoi de votre message ❌", - success: 'Merci pour votre message 😉', - form: { - placeholder: 'tim@apple.com', - error: 'Erreur lors de la connexion ❌', - } + success: 'Merci pour votre message 😉' }, newsletter: { diff --git a/src/pages/blog/_slug.vue b/src/pages/blog/_slug.vue index 31125ac..2c8ff3a 100755 --- a/src/pages/blog/_slug.vue +++ b/src/pages/blog/_slug.vue @@ -137,7 +137,7 @@ export default defineComponent({ const likes = ref(0) useAsync(() => { - $axios.get(`/posts/${slug.value}`, { + $axios.get(`/api/posts/${slug.value}`, { headers: { 'Authorization': `Bearer ${process.env.API_TOKEN}` } @@ -151,7 +151,7 @@ export default defineComponent({ const handleLike = async () => { if (liked.value) { - const response = await $axios.post(`/posts/${post.value?.slug}/unlike`, {}, { + const response = await $axios.post(`/api/posts/${post.value?.slug}/unlike`, {}, { headers: { 'Authorization': `Bearer ${process.env.API_TOKEN}` } @@ -165,7 +165,7 @@ export default defineComponent({ app.error({statusCode: 500}) } } else { - const response = await $axios.post(`/posts/${post.value?.slug}/like`, {}, { + const response = await $axios.post(`/api/posts/${post.value?.slug}/like`, {}, { headers: { 'Authorization': `Bearer ${process.env.API_TOKEN}` } diff --git a/src/pages/guestbook.vue b/src/pages/guestbook.vue index a67f66e..e078dd4 100644 --- a/src/pages/guestbook.vue +++ b/src/pages/guestbook.vue @@ -34,15 +34,10 @@ export default defineComponent({ const guestbook_messages = ref([]) useAsync(async () => { - await $axios.get('guestbook', { + await $axios.get('/api/guestbook', { headers: { 'Authorization': `Bearer ${process.env.API_TOKEN}` - }, - proxy: { - protocol: 'https', - host: 'https://api.arthurdanjou.fr', - port: 80, - }, + } }) .then(response => { guestbook_messages.value = response.data.guestbook_messages diff --git a/yarn.lock b/yarn.lock index 1a9bd83..8b45071 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1373,22 +1373,7 @@ webpack-node-externals "^3.0.0" webpackbar "^4.0.0" -"@nuxtjs/auth-next@5.0.0-1624817847.21691f1": - version "5.0.0-1624817847.21691f1" - resolved "https://registry.yarnpkg.com/@nuxtjs/auth-next/-/auth-next-5.0.0-1624817847.21691f1.tgz#28b92625ac5817d8083f8b42dd184a88caefbe96" - integrity sha512-PsHhLtzglMnwM2o16mgM7zQ3KwTI7AIg2ja3IFYujbs9s1w8HvnRD3byMRj1WZo0vXEBRh3u3nHxKEBIbFe1Xg== - dependencies: - "@nuxtjs/axios" "^5.13.0" - axios "^0.21.1" - body-parser "^1.19.0" - consola "^2.15.3" - cookie "^0.4.1" - defu "^3.2.2" - hasha "^5.2.2" - jwt-decode "^3.1.2" - requrl "^3.0.2" - -"@nuxtjs/axios@^5.13.0", "@nuxtjs/axios@^5.13.6": +"@nuxtjs/axios@^5.13.6": version "5.13.6" resolved "https://registry.yarnpkg.com/@nuxtjs/axios/-/axios-5.13.6.tgz#6f4bbd98a3a7799a5d2c0726c6ad2a98aa111881" integrity sha512-XS+pOE0xsDODs1zAIbo95A0LKlilvJi8YW0NoXYuq3/jjxGgWDxizZ6Yx0AIIjZOoGsXJOPc0/BcnSEUQ2mFBA== @@ -2623,22 +2608,6 @@ bn.js@^5.0.0, bn.js@^5.1.1: resolved "https://registry.yarnpkg.com/bn.js/-/bn.js-5.2.0.tgz#358860674396c6997771a9d051fcc1b57d4ae002" integrity sha512-D7iWRBvnZE8ecXiLj/9wbxH7Tk79fAh8IHaTNq1RWRixsS02W+5qS+iE9yq6RYl0asXx5tw0bLhmT5pIfbSquw== -body-parser@^1.19.0: - version "1.19.0" - resolved "https://registry.yarnpkg.com/body-parser/-/body-parser-1.19.0.tgz#96b2709e57c9c4e09a6fd66a8fd979844f69f08a" - integrity sha512-dhEPs72UPbDnAQJ9ZKMNTP6ptJaionhP5cBb541nXPlW60Jepo9RV/a4fX4XWW9CuFNK22krhrj1+rgzifNCsw== - dependencies: - bytes "3.1.0" - content-type "~1.0.4" - debug "2.6.9" - depd "~1.1.2" - http-errors "1.7.2" - iconv-lite "0.4.24" - on-finished "~2.3.0" - qs "6.7.0" - raw-body "2.4.0" - type-is "~1.6.17" - boolbase@^1.0.0, boolbase@~1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/boolbase/-/boolbase-1.0.0.tgz#68dff5fbe60c51eb37725ea9e3ed310dcc1e776e" @@ -2808,11 +2777,6 @@ bytes@3.0.0: resolved "https://registry.yarnpkg.com/bytes/-/bytes-3.0.0.tgz#d32815404d689699f85a4ea4fa8755dd13a96048" integrity sha1-0ygVQE1olpn4Wk6k+odV3ROpYEg= -bytes@3.1.0: - version "3.1.0" - resolved "https://registry.yarnpkg.com/bytes/-/bytes-3.1.0.tgz#f6cf7933a360e0588fa9fde85651cdc7f805d1f6" - integrity sha512-zauLjrfCG+xvoyaqLoV8bLVXXNGC4JqlxFCutSDWA6fJrTo2ZuvLYTqZ7aHBLZSMOopbzwv8f+wZcVzfVTI2Dg== - cacache@^12.0.2: version "12.0.4" resolved "https://registry.yarnpkg.com/cacache/-/cacache-12.0.4.tgz#668bcbd105aeb5f1d92fe25570ec9525c8faa40c" @@ -3324,11 +3288,6 @@ constants-browserify@^1.0.0: resolved "https://registry.yarnpkg.com/constants-browserify/-/constants-browserify-1.0.0.tgz#c20b96d8c617748aaf1c16021760cd27fcb8cb75" integrity sha1-wguW2MYXdIqvHBYCF2DNJ/y4y3U= -content-type@~1.0.4: - version "1.0.4" - resolved "https://registry.yarnpkg.com/content-type/-/content-type-1.0.4.tgz#e138cc75e040c727b1966fe5e5f8c9aee256fe3b" - integrity sha512-hIP3EEPs8tB9AT1L+NUqtwOAps4mk2Zob89MWXMHjHWg9milF/j4osnnQLXBCBFBk/tvIG/tUc9mOUJiPBhPXA== - convert-source-map@^1.7.0: version "1.8.0" resolved "https://registry.yarnpkg.com/convert-source-map/-/convert-source-map-1.8.0.tgz#f3373c32d21b4d780dd8004514684fb791ca4369" @@ -4955,17 +4914,6 @@ htmlparser2@^6.1.0: domutils "^2.5.2" entities "^2.0.0" -http-errors@1.7.2: - version "1.7.2" - resolved "https://registry.yarnpkg.com/http-errors/-/http-errors-1.7.2.tgz#4f5029cf13239f31036e5b2e55292bcfbcc85c8f" - integrity sha512-uUQBt3H/cSIVfch6i1EuPNy/YsRSOUBXTVfZ+yR7Zjez3qjBz6i9+i4zjNaoqcoFVI4lQJ5plg63TvGfRSDCRg== - dependencies: - depd "~1.1.2" - inherits "2.0.3" - setprototypeof "1.1.1" - statuses ">= 1.5.0 < 2" - toidentifier "1.0.0" - http-errors@~1.7.2: version "1.7.3" resolved "https://registry.yarnpkg.com/http-errors/-/http-errors-1.7.3.tgz#6c619e4f9c60308c38519498c14fbb10aacebb06" @@ -5015,7 +4963,7 @@ human-signals@^2.1.0: resolved "https://registry.yarnpkg.com/human-signals/-/human-signals-2.1.0.tgz#dc91fcba42e4d06e4abaed33b3e7a3c02f514ea0" integrity sha512-B4FFZ6q/T2jhhksgkbEW3HBvWIfDW85snkQgawt07S7J5QXTk6BkNV+0yAeZrM5QpMAdYlocGoljn0sJ/WQkFw== -iconv-lite@0.4.24, iconv-lite@^0.4.24: +iconv-lite@^0.4.24: version "0.4.24" resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.4.24.tgz#2022b4b25fbddc21d2f524974a474aafe733908b" integrity sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA== @@ -5605,11 +5553,6 @@ jsonfile@^6.0.1: optionalDependencies: graceful-fs "^4.1.6" -jwt-decode@^3.1.2: - version "3.1.2" - resolved "https://registry.yarnpkg.com/jwt-decode/-/jwt-decode-3.1.2.tgz#3fb319f3675a2df0c2895c8f5e9fa4b67b04ed59" - integrity sha512-UfpWE/VZn0iP50d8cz9NrZLM9lSWhcJ+0Gt/nm4by88UL+J1SiKN8/5dkjMmbEzwL2CAe+67GsegCbIKtbp75A== - kind-of@^3.0.2, kind-of@^3.0.3, kind-of@^3.2.0: version "3.2.2" resolved "https://registry.yarnpkg.com/kind-of/-/kind-of-3.2.2.tgz#31ea21a734bab9bbb0f32466d893aea51e4a3c64" @@ -7826,11 +7769,6 @@ q@^1.1.2: resolved "https://registry.yarnpkg.com/q/-/q-1.5.1.tgz#7e32f75b41381291d04611f1bf14109ac00651d7" integrity sha1-fjL3W0E4EpHQRhHxvxQQmsAGUdc= -qs@6.7.0: - version "6.7.0" - resolved "https://registry.yarnpkg.com/qs/-/qs-6.7.0.tgz#41dc1a015e3d581f1621776be31afb2876a9b1bc" - integrity sha512-VCdBRNFTX1fyE7Nb6FYoURo/SPe62QCaAyzJvUjwRaIsc+NePBEniHlvxFmmX56+HZphIGtV0XeCirBtpDrTyQ== - qs@^6.5.2, qs@^6.9.4: version "6.10.1" resolved "https://registry.yarnpkg.com/qs/-/qs-6.10.1.tgz#4931482fa8d647a5aab799c5271d2133b981fb6a" @@ -7896,16 +7834,6 @@ range-parser@^1.2.1, range-parser@~1.2.1: resolved "https://registry.yarnpkg.com/range-parser/-/range-parser-1.2.1.tgz#3cf37023d199e1c24d1a55b84800c2f3e6468031" integrity sha512-Hrgsx+orqoygnmhFbKaHE6c296J+HTAQXoxEF6gNupROmmGJRoyzfG3ccAveqCBrwr/2yxQ5BVd/GTl5agOwSg== -raw-body@2.4.0: - version "2.4.0" - resolved "https://registry.yarnpkg.com/raw-body/-/raw-body-2.4.0.tgz#a1ce6fb9c9bc356ca52e89256ab59059e13d0332" - integrity sha512-4Oz8DUIwdvoa5qMJelxipzi/iJIi40O5cGV1wNYp5hvZP8ZN0T+jiNkL0QepXs+EsQ9XJ8ipEDoiH70ySUJP3Q== - dependencies: - bytes "3.1.0" - http-errors "1.7.2" - iconv-lite "0.4.24" - unpipe "1.0.0" - rc9@^1.2.0: version "1.2.0" resolved "https://registry.yarnpkg.com/rc9/-/rc9-1.2.0.tgz#ef098181fdde714efc4c426383d6e46c14b1254a" @@ -8140,11 +8068,6 @@ requires-port@^1.0.0: resolved "https://registry.yarnpkg.com/requires-port/-/requires-port-1.0.0.tgz#925d2601d39ac485e091cf0da5c6e694dc3dcaff" integrity sha1-kl0mAdOaxIXgkc8NpcbmlNw9yv8= -requrl@^3.0.2: - version "3.0.2" - resolved "https://registry.yarnpkg.com/requrl/-/requrl-3.0.2.tgz#d376104193b02a2d874dde68454c2db2dfeb0fac" - integrity sha512-f3gjR6d8MhOpn46PP+DSJywbmxi95fxQm3coXBFwognjFLla9X6tr8BdNyaIKNOEkaRbRcm0/zYAqN19N1oyhg== - resolve-from@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/resolve-from/-/resolve-from-3.0.0.tgz#b22c7af7d9d6881bc8b6e653335eebcb0a188748" @@ -9162,7 +9085,7 @@ type-fest@^0.8.0: resolved "https://registry.yarnpkg.com/type-fest/-/type-fest-0.8.1.tgz#09e249ebde851d3b1e48d27c105444667f17b83d" integrity sha512-4dbzIzqvjtgiM5rw1k5rEHtBANKmdudhGyBEajN01fEyhaAIhsoKNy6y7+IN93IfpFtwY9iqi7kD+xwKhQsNJA== -type-is@^1.6.16, type-is@~1.6.17: +type-is@^1.6.16: version "1.6.18" resolved "https://registry.yarnpkg.com/type-is/-/type-is-1.6.18.tgz#4e552cd05df09467dcbc4ef739de89f2cf37c131" integrity sha512-TkRKr9sUTxEH8MdfuCSP7VizJyzRNMjj2J2do2Jr3Kym598JVdEksuzPQCnlFPW4ky9Q+iA+ma9BGm06XQBy8g== @@ -9340,7 +9263,7 @@ universalify@^2.0.0: resolved "https://registry.yarnpkg.com/universalify/-/universalify-2.0.0.tgz#75a4984efedc4b08975c5aeb73f530d02df25717" integrity sha512-hAZsKq7Yy11Zu1DE0OzWjw7nnLZmJZYTDZZyEFHZdUhV8FkH5MCfoU1XMaxXovpyW5nq5scPqq0ZDP9Zyl04oQ== -unpipe@1.0.0, unpipe@~1.0.0: +unpipe@~1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/unpipe/-/unpipe-1.0.0.tgz#b2bf4ee8514aae6165b4817829d21b2ef49904ec" integrity sha1-sr9O6FFKrmFltIF4KdIbLvSZBOw=