R
R
Romi2021-04-14 10:47:58
Laravel
Romi, 2021-04-14 10:47:58

Laravel + Vue.js (not CLI, via CDN in Blade) - how to properly organize global variables (like .env)?

My case is not quite normal :)

Vue.js is connected to Blade templates via the script tag, well, relatively speaking, via CDN, but at the same time, it works with API via Axios (it is also via CDN).

And, for example, look at the situation, I write something like this in different files:

axios.get('https://site.com/api/item/create')

but, of course, I want ' https://site.com/api ', for example, to take it out of brackets somehow, so as not to duplicate in each Blade template.

And, as I understand it, there will still be many other similar issues that are standardly solved in some Nuxt.js, but which I don’t really understand how best to do here.

All sorts of things come to mind, like - "pass such variables from Laravel itself, through PHP", well, that is, for example ' https://site.com/api' can also be substituted as a PHP variable when generating a template.

But, something confuses me in this: D

What are the good practices for this case?

Thank you.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question