Skip to content

Commit

Permalink
Allow using environment Google key
Browse files Browse the repository at this point in the history
Necesary for prerendering. In that context, there is no referer available, which is required for our public google key.
  • Loading branch information
casperboone committed Oct 31, 2024
1 parent e54b8fb commit f394ae7
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 12 deletions.
15 changes: 6 additions & 9 deletions dwhdelft.nl/components/pages/contact/Map.vue
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
<script setup>
const googleKey = useRuntimeConfig().public.googleKey
const mapUrl = `https://www.google.com/maps/embed/v1/place?key=${googleKey}&q=DWH, Delft`
</script>

<template>
<iframe
width="100%"
height="550"
style="border: 0"
loading="lazy"
allowfullscreen
src="https://www.google.com/maps/embed/v1/place?key=AIzaSyDwi_l2R3qDWkh2HN8_AmIpy7mk8Ij7nk8
&q=DWH, Delft"
/>
<iframe width="100%" height="550" style="border: 0" loading="lazy" allowfullscreen :src="mapUrl" />
</template>
4 changes: 3 additions & 1 deletion shared/composables/useGoogleDrive.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
async function fetchFiles(folderId) {
const key = useRuntimeConfig().public.googleKey

try {
const url =
`https://www.googleapis.com/drive/v3/files` +
`?orderBy=name desc` +
`&q='${folderId}'%20in%20parents` +
`&fields=files(id, name, webContentLink, webViewLink, iconLink, thumbnailLink)` +
`&key=AIzaSyDwi_l2R3qDWkh2HN8_AmIpy7mk8Ij7nk8`
`&key=${key}`

const response = await fetch(url)

Expand Down
8 changes: 6 additions & 2 deletions shared/nuxt.config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

import { fileURLToPath } from 'url'
import { dirname, join } from 'path'

Expand Down Expand Up @@ -31,7 +30,7 @@ export default defineNuxtConfig({
},
},
svgo: {
defaultImport: 'component'
defaultImport: 'component',
},
css: [relativePath('assets/css/main.css')],
postcss: {
Expand All @@ -57,4 +56,9 @@ export default defineNuxtConfig({
],
},
},
runtimeConfig: {
public: {
googleKey: process.env.GOOGLE_KEY || 'AIzaSyDwi_l2R3qDWkh2HN8_AmIpy7mk8Ij7nk8',
},
},
})

0 comments on commit f394ae7

Please sign in to comment.