How to solve "Access-Control-Allow-Origin"-Issue in vue.js? - javascript

Im new to vue.js and webpack. I currently have a very big trouble to archive the next step: communicate with real-world-apis in a dev env.
what i currently do is:
npm run dev
my application calls an remote api to which i have no access.
then i run into the Access-Control-Allow-Origin-Issue.
If i build my application and run it with xampp everything works fine.
What can i do, to simply develope my application instead to hassle with that security thing?
I have tried to create a proxy, so i have already looked at:
npm cors (node-cors-client and node-cors-server) - but how does that apply to my vue app?
socket.io - but it seems to be overkill
http-server - but i got the same issues here
nuxt - could work, but then i need to refactor my vue.js app to nuxt and i dont know if this works then
any suggestions? Thanks!

Solved:
I ended up with a PHP-API
The PHP-API runs with xampp under port 80
The Vue.js-App runs with npm dev server under port 8080
The CORS-Hassle must solved then in the PHP-Script with:
https://stackoverflow.com/a/9866124/3918455

Related

Strapi deployment

I am new to Strapi and I found it really good, I got my website in development mode locally working perfectly fine but I can not get my head around or find any good guide how to host Strapi on Debian Linux server, that I have, to be part of website and to access Strapi control panel for example mywebiste.com/admin so I can add content as blog posts directly by logging in to website admin part. Is that possible or I must use some services like Heroku. if someone can provide in short step by step what to do I will really appreciate that. I tried already create new Strapi project inside public_html folder but its not working
I use strapi on my project . I hosted strapi on pm2 package. Its very easy.
this documention https://docs.strapi.io/developer-docs/latest/guides/process-manager.html#install-pm2
don't forget add startup Ubuntu to pm2. Otherwise when Ubuntu started then not starting pm2
I suggest use Ubuntu.
Nginx Configuration
In order to deploy it to a Linux server, you need to install nginx, and set it up. You can find instructions in official documentation: https://docs.strapi.io/developer-docs/latest/setup-deployment-guides/deployment/optional-software/nginx-proxy.html#nginx-virtual-host

ExpressJS webseite works local but returns 403 Forbidden online

I'm trying to get this example ExpressJS app running on my server.
Offline (on localhost) it is working correctly after running npm start.
I uploaded all files, installed everything through npm install, started the nodemon through SSH npm startand got the App Running response.
If I try now to open the URL of the website it returns 403 Forbidden.
What do I need to change to make it work?
(It's my first time working with ExpressJS - maybe it's just a noob issue. Could this be a HOST or PORT issue?)

Weird CORS errors on fresh vue cli project

I just started building my second Vue project, and for the first time I wanted to use the Vue CLI and NPM rather than just loading Vue via CDN.
Installing the CLI and setting up the project worked without problems, but when I ran "npm run serve" and navigated to localhost:8080 in my browser (latest Firefox) to see if it worked, I got the following error message in my browser console multiple times:
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://10.126.86.51:8080/sockjs-node/info?t=1584021154635. (Reason: CORS request did not succeed).
I also get this error message once right after loading the page:
[WDS] Disconnected!
Does anyone know what these errors mean, why I get them and how I can get rid of them?
The first one seems to be related to some kind of cross-origin call that the app is making using the host's actual IP rather than localhost, but I can't think of any reason why it would, given that I literally just installed and served the example project and did not change anything after running "vue create"
Edit: I am on Ubuntu 19.10 Desktop
First of all, what kind of OS you are working on? If you are working on unix based systems, a service (like nginx) could produce this error. If so, try stopping it.
Afterwards I would try to run your application from vue ui.
Type in your terminal:
vue ui
This starts the web based graphical user interface of vue cli. You can handle your app development from there by starting your service and run your build command.
ATTENTION: you must add (import, NOT create) your project (root folder) to the UI.
If you get the same error inside your browser console, set up a vagrant box. First steps are explained here:
https://www.vagrantup.com/intro/getting-started/
Follow instructions for project setup.
Simplest way would be running
vagrant init
inside your project folder. Therefore you don't have to setup a new project.
After running the init command, try running
npm run serve
or use vue UI instead (as explained above), if you prefer it.
If the problem still exists, more infos about your OS would be helpful.

Meteor server crashes very frequently without any error

I am working with the Meteor application and I deployed the same over EC2 instance. It was working fine till a few days back.
But now the server process kill automatically without any error log or
console
I tried to get the error but unfortunately, as there are not any logs I am unable to find out why the server is crashing again and again.
I have a medium EC2 machine on which the application is running.
I am using nohup for running the application in the background.
Below is the command I used to start the server:-
nohup meteor --settings SETTINGS-PRODUCTION.JSON &
I am wondering to know about server crashes due to nohup or some other reason is there.
Please let me know how we can console uncaught exception in the meteor-like we do in express.
What should I use to auto restart the server if the process is killed
by any error or exception?
Any help would be much appreciated!
Thanks
Using nohup is quite a low-tech solution. Things like Phusion Passenger, PM2, or forever do a better job.
Also your docker container can be configured to automatically restart the process.
Even better is a tool called Meteor Up, which makes it really simple to deploy Meteor apps to EC2.
EASILY DEPLOY YOUR APP Meteor Up is a production quality Meteor app
deployment tool.
Install with one command:
$ npm install --global mup
http://meteor-up.com/

Connect to OpenVPN server through Node.js

I’m trying to create a GUI client for connecting to OpenVPN servers using electron and node but I’m struggling to figure out how to actually connect to the servers using the .ovpn files.
My question is what is the best way to connect to an OpenVPN server using node? Would it be best to Tun terminal commands like
“openvpn—config path to config”
Or is there another way applications like tunnelblick do it that might be easier or more efficient?
Hello I have been working with electron and ovpn on my last project, so here are a few tips.
VPNs require admin/root privilege in order to get setup, so running child_process.spawn on openvpn --config <path> will fail unless your electron app is being ran via sudo/admin privilege.
You can also use electron-sudo package, link here. This is basically a child process spawn with sudo/admin. Aka, app runs normally, but vpn command runs with sudo.
However, if your client is sketchy about giving you sudo/admin, the VPN must be ran separately prior to launching your app.
All in all its a admin/sudo thing.
Hope this helps.

Categories