How to fix the "Not allowed to load local resource" Vue.js - vue.js

I tried to load some icons and logos into my site using localhost, files are detected but are not loaded and it says "Not allowed to load local resource", I also tried to run the app using "npm install -g http-server" in terminal, but I had another error: "Failed to load resource: the server responded with a status of 404 (Not Found) #build.js:1"

There are two common options for loading images.
Through the public folder. e.g. <img src='/image/myImageName.png'>
Note: by specifying the root directory / vue is directed to the public folder
Or through the assets folder. e.g. <img src='#/assets/images/myImageName.png'>
Note: by supplying the # sign vue is directed to the src directory

Related

How to get rid of react manifest.json error

I'm trying to use the json-server and when I run the command json-server --watch jb.json the home link, e.g., https://localhost:3000, is not rendered due to the following error in the console.
Essentially this image below is where I'm trying to land when clicking on the link.
✅ Solution: After asking around, I found that creating a json-server.json file in the root of your project and adding the following custom configuration works for me:
{
.`.`.`,
"static": "./node_modules/json-server/public"
}
Essentially, you call the home route, e.g., https://localhost:3000, from the static root directory, not the public directory, because it's located in your app. https://github.com/typicode/json-server/issues/1100

Shopify app development -production build failing to serve assets folder in dist/client/assets

Trying to get my Shopify app to work on a server. When I run npm run serve nothing is failing, OAUTH is working, but the index.html is throwing an error saying it can't get the static files in the dist/client/assets folder. Here is my server code, here is my index.html file, and the error Im getting. index.html
server code
error

Statically served vue-router app by Flask shows 404 for custom pages on Heroku

I've gone through several Stack Overflow pages and the official Vue guide, but my app still returns 404 results when going to a different page.
The structure of my app looks like this, with a client folder that has the Vue app and a server folder containing app.py that statically serves the index.html in the client/dist folder through Flask.
Contents of static.json are as outlined in the guide:
{
"root": "client/dist",
"clean_urls": true,
"routes": {
"/**": "index.html"
}
}
with just modified root folder to go to client/dist. Running the app locally with npm run serve works, as does opening it up on its Heroku page and clicking on the nav. However, directly going to a page, such as /translate, always returns 404.
I have installed the following buildpacks:
=== readiglot Buildpack URLs
1. heroku/nodejs
2. heroku/python
3. https://github.com/heroku/heroku-buildpack-static
The app is hosted here: https://www.readiglot.herokuapp.com.
On npm run build from the root directory, the dist folder is built by Heroku in the client folder.
Am I missing something? Could anyone advise as to additional configuration?
The answer is in the app.py file - you need to statically serve the file using a catch all route.
#app.route("/", defaults={"path": ""})
#app.route("/<string:path>")
#app.route("/<path:path>")
def index(path):
return app.send_static_file("index.html")
By putting the serve_static_file in the Flask app to redirect from all other routes, 404 only shows up on a true 404.

sails.js stopped to work after cloning from repository

After adding to git and cloning sails.js application back to another desktop my application stopped to work correctly. e.g. I am able to successfully run sails lift command, however when trying to load login page I see that the page is not loaded properly:
and I receive multiple errors in browser console (back end console is ok and does not drop any errors):
cloud.setup.js:13 Uncaught ReferenceError: Cloud is not defined
at cloud.setup.js:13
Uncaught ReferenceError: parasails is not defined
at ajax-button.component.js:12
ajax-form.component.js:20 Uncaught ReferenceError: parasails is not defined
at ajax-form.component.js:20
Uncaught ReferenceError: parasails is not defined
at js-timestamp.component.js:15
...
I checked node_modules folder and parasails is included there.
I didn't include node_module to my repo as I can always run npm install after cloning.
I managed to create and successfully run a new sails.js application on my desktop without any issues.
So, there must be an error with the files I pushed or didn't pushed to git.
In .gitignore file I had dependencies/ folder excluded.
That rule was excluding any file in assets/dependencies subfolder, where a number of sails.js files are located, e.g. parasails.js, etc.

How to produce deployment version of a Vue.js CLI site?

I have setup a Vue.js CLI project
I ran npm run dev and it runs in my browser at port 8080
I made some changes to the site
I typed npm run build.
moved the contents of the dist folder under an Apache server
but I get the error
Failed to load resource: the server responded with a status of 404(Not
Found)
What else do I need to copy here to avoid this error, or what can't it load exactly?
Ok, I figured it out:
Because I put the files in a subdirectory, I had to go into the index.html file and search and replace /static with static.
From: <link href=/static/css/app.fd50d336198a48f4f49d999710298aad.css
To: <link href=static/css/app.fd50d336198a48f4f49d999710298aad.css