14-Oct-2024, 11:28 PM
I would like to know how to integrate Commentics iframe with Nuxt or Vuejs
this is my code so far
The config.public.commentsUrl is linked to my .env file with the url to the embed like this http://your-domain.com/comments/embed.js
I get Forbidden
You don't have permissions to access this folder where the iframe is supposed to be
this is my code so far
Code:
<template>
<div id="commentics">
<!-- Commentics will load here -->
</div>
</template>
<script setup>
import { onMounted } from 'vue';
import { useRuntimeConfig } from '#app'; // Import useRuntimeConfig to access environment variables
const config = useRuntimeConfig();
onMounted(() => {
if (process.client) {
// Load Commentics iframe for client-side rendering
const commenticsContainer = document.getElementById('commentics');
const iframe = document.createElement('iframe');
// Use the commentsUrl from the config
iframe.src = config.public.commentsUrl; // Fetch the URL from public config
iframe.width = '100%';
iframe.height = '600px'; // Adjust the height as needed
iframe.frameBorder = '0';
iframe.scrolling = 'no';
commenticsContainer.appendChild(iframe);
}
});
</script>
<style scoped>
/* Optional: style adjustments for the iframe */
iframe {
width: 100%;
height: 100%;
}
</style>
The config.public.commentsUrl is linked to my .env file with the url to the embed like this http://your-domain.com/comments/embed.js
I get Forbidden
You don't have permissions to access this folder where the iframe is supposed to be