I need to pull in my Stripe keys from my Laravel .env
file and pass it into my Vue component.
I read some similar questions on SO and the Laravel docs that mention doing it by simply adding the MIX
prefix, and I can call process.env.MIX_STRIPE_KEY
anywhere in my JS.
.env
STRIPE_KEY=pk_test_xxxxxxxxxxxxxxxxxx
STRIPE_SECRET=sk_test_xxxxxxxxxxxxxxxxxxx
MIX_STRIPE_KEY="${STRIPE_KEY}"
MIX_STRIPE_SECRET="${STRIPE_SECRET}"
In my Vue Component:
<template>
{{ stripe }} // Renders process.env.MIX_STRIPE_KEY (Not the actual key?)
...code
</template>
<script>
export default {
data: function() {
return {
stripe: Stripe('process.env.MIX_STRIPE_KEY'),
...
After I did this I recompiled by npm run dev, production, watch
tried all of them... Still not getting the Stripe key to show in the app.js
file.
Speaking of the app.js
file. I tried adding it in there as well.
const app = new Vue({
el: '#app',
data:{
stripeKey: 'process.env.MIX_STRIPE_KEY',
},
Then tried calling {{ stripKey }}
in the Vue component, but that didn't render correctly either.
Any help on this would be appreciated.