This is a PERN app. I don't remember ever getting this error and I haven't found any records when doing a Google search.
I don't see anything wrong in the index.html:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" />
<meta
name="description"
content="Web site created using create-react-app"
/>
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
<!--
manifest.json provides metadata used when your web app is installed on a
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
-->
<!-- <link rel="manifest" href="%PUBLIC_URL%/manifest.json" /> -->
<!--
Notice the use of %PUBLIC_URL% in the tags above.
It will be replaced with the URL of the `public` folder during the build.
Only files inside the `public` folder can be referenced from the HTML.
Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
work correctly both with client-side routing and a non-root public URL.
Learn how to configure a non-root public URL by running `npm run build`.
-->
<title>React App</title>
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>
<!--
This HTML file is a template.
If you open it directly in the browser, you will see an empty page.
You can add webfonts, meta tags, or analytics to this file.
The build step will place the bundled scripts into the <body> tag.
To begin the development, run `npm start` or `yarn start`.
To create a production bundle, use `npm run build` or `yarn build`.
-->
</body>
</html>
Any idea where it comes from? I get it as soon as I start the app.
I'm just a beginner but it happens when you are passing the wrong URL to the fetch function, suppose that your db.json file is running on port 8000 and you are passing port 3000, that's why.
useFetch("http://localhost:3000/blogs/" + id);
Instead, try this, it might helps. :)
useFetch("http://localhost:8000/blogs/" + id);
Hope it helps.
So I had this same error when I installed npm gh-pages. My solution was to delete the Homepage link in package.json and it worked.
I had the same problem .
If you are using node server, install this npm install body-parser
and add these lines in your server-side code
const bodyParser = require("body-parser"); router.use(bodyParser.json());
I'm new at this, but I found if I added a proxy to my package.json (client side, not server side) it worked! It looks like this in package.json (placed above my dependencies): "proxy": "http://localhost:3001", . I believe it's because the client side can't read it, and the proxy tells it to pass it to the server side which can read it.
I got the same error while deploying the React app on Vercel. Turns out, I forgot to add environment variables to the project settings on Vercel.
Check if you are calling your api prefixing the protocol, like this 'https://apiurl...', not like this 'api.something'
Faced the same issue and it was my json path was incorrect. Initially it was fetch('./movies.json') which was incorrect path.
Fix it and now working fine:
useEffect(() => {
fetch('../movies.json')
.then(res => res.json())
.then(data => setMovies(data.posts))
}, [])
I was trying to fetch data from the backend into my react application, with out mentioning the proper path of the url in the loader function of the react-router library, hence this issue occured and once I defined the correct path, it worked just fine.
const response = await fetch("http://localhost:8080/events");
I forgot to mention "events" in the url.
I am using vite purely as dev server with a backend server that does the file serving for me and has no connection to vite itself. My vite application lives under nested path. Thats why I set the base-url as specified in the config to '/my/path/'. This works well and everything is served correctly.
Once I run build, it creates a dist folder with a manifest file. My index HTML that is served by the backend server either includes the vite devserver in dev more or loads the main.ts as specified by the maninifest.json { "src/main.ts": { "file": "assets/main.b3ed3483.js", ...}}. Therefore my index HTML looks somewhat like this:
<?php if($dev): ?>
<script type="module" src="http://localhost:3000/#vite/client"></script>
<script type="module" src="http://localhost:3000/src/main.ts"></script>
<?php else: ?>
<?php $entry = parseJson('dist/manifest.json'); /* pseudocode */ ?>
<link rel="stylesheet" href="/my/path/dist/<?= $entry.css[0] ?>" />
<script type="module" src="/my/path/dist/<?= $entry.file ?>"></script>
<?php endif ?>
Now, I have the problem, that whenever a module is imported, it tries to load it from /my/path/assets instead of my/path/dist/assets. I tried changing the basepath to /my/path/dist/ but now obviously the path arent resolved in dev correctly. What do I have to do to make this work?
I am not sure if I completely understand the src paths in your script tags but I think this should work, though you might need to make some changes to make your src paths match.
Option one: If you are using linux, I would create a symbolic link from /my/path/ to/dist/assets/ e.g. ln -s -r ./dist/assets/ assets (-s for symbolic link and -r for relative links). This will provide two paths to the same directory, one from /my/path/assets and one from /my/path/dist/assets/.
Option two: use a relative base path i.e. set base in your vite config to ''. Note: in vite 2.x there is an issue where if you have multiple entry points the asset path will be incorrect. There is a fix merged for vite 3.0.
I have navlink defined as follows
<NavLink href="/intro"></NavLink>
In dev it works fine as the root of the site is at the same level as the blazor app.
In prod I have to put the blazor site inside a folder in the default iis website.
So my url becomes something like this
http://something/apps/cor/
So the <NavLink href="/intro"></NavLink> ends up trying to go to http://something/intro instead http://something/apps/cor/intro
I tried both /intro and intro and the both result in the wrong behavior. I am not getting how to make those links relative to blazor root not iis root.
Dot before the path. ./intro is how you do it
on index.html you should have <base href="/apps/cor/" />
I had to do this trick in _Layout.cshtml:
#inject IWebHostEnvironment Environment;
// in <head> :
#if (Environment.IsDevelopment())
{
<base href="~/" />
}
else
{
<base href="~/myApp" />
}
then either <NavLink href="page"></NavLink> or <NavLink href="./page"></NavLink> works.
On localhost: https://localhost:44393/page
On server: https://example.com/myApp/page
I started today with LESS. It looks awesome to work with and I will need it on my internship soon.
My less code:
#color: #4D926F;
body {
background-color: #color;
}
Not anything special.
My html:
<!Doctype HTML>
<html>
<head>
<title>#ViewBag.Title</title>
<link href="#Url.Content("~/Content/style.less")" type="stylesheet" rel="stylesheet/less" />
<script src="#Url.Content("~/Scripts/less-1.4.1.min.js")" type="text/javascript"></script>
</head>
<body>
#RenderBody()
</body>
</html>
The Less script file is downloaded from http://lesscss.org/
My file structure:
The result:
FileError: 'http://localhost:58123/Content/style.less' wasn't found (404)
in style.less
Index
When I install dotless via Package Manager everything works perfect.
My question is what do I need to runn it without Dotles? I dont have problems installing Dotless or using it. I just want to know whats the missing link why the LESS gives that error. Why do I get a 404 error when the file is there?
Dotless compiles the .less to .css. So you would need to add a reference to the resulting .css that Dotless compiles. Also you would want to remove this line from your code.
<link href="#Url.Content("~/Content/style.less")" type="stylesheet" rel="stylesheet/less" />
Like title, that rule:
RewriteRule pagtwo/pic/(.*) index.php?pic=$1 [PT,QSA]
Rule working, but not the file included by subdirectory for example
<link type="text/css" rel="stylesheet" href="css/base.css" media="all">
<img src="imgs/image.jpg">
and goes on
Directories are css, imgs and js, why they do not included correctly? Must I insert the absolute path for that directory?
Try adding this to you page header:
<base href="/">
Because you're using relative paths, what would normally resolve relatively from / won't woek when resolving relative from /pagtwo/pic/.