I'm attempting to create a details page with dynamic routing. My general routes look like this:
src /
routes /
products /
[id].svelte
index.svelte
When I try to load http://localhost:3000/products/1234 I get a 404 and I'm not entirely sure why. Looking through the docs shows this should be valid.
This is the error I get:
Not found: /products/123
Error: Not found: /products/123
at resolve (file:///C:/projects/sveltekit/ecommerce/node_modules/#sveltejs/kit/dist/ssr.js:1824:14)
at async Object.handle (c:/projects/sveltekit/ecommerce/src/hooks.ts:8:14)
at async respond (file:///C:/projects/sveltekit/ecommerce/node_modules/#sveltejs/kit/dist/ssr.js:1760:10)
at async file:///C:/projects/sveltekit/ecommerce/node_modules/#sveltejs/kit/dist/chunks/index.js:4374:24
EDIT: The route /products works as expected.
A silly typo is what caused all of this in my source. Nothing more. product != products for future reference.
Related
I am trying to load an image using React using the following code:
const DogImage = require("../../public/dog.jpg");
console.log(DogImage);
...
<img src={DogImage} width="100px"/>
but I am getting the error:
the console log statement gives:
Please let me know if you have any suggestions or if I can provide more info!
EDIT: The file listed in the console.log (dist/8ce0...) exists when built
The path is going into the default property, which is a special property used by the import syntax. Try:
import DogImage from '../../public/dog.jpg';
OR
const DogImage = require('../../public/dog.jpg').default;
Anything else would require digging into the webpack config.
I have a spring boot app and a controller that server static webpage(React build):
#Controller
#RequestMapping("/test")
public class HomeController {
#GetMapping("/")
public String index() {
return "index.html";
}
...
index.html is located at: ../resources/static/index.html
also in application.yml:
spring:
mvc:
static-path-pattern: /test/**
I am having two problems(problem 2 is the main issue):
I must call the following url with the trailing '/' at the end: http://localhost:8100/test/ I would like for http://localhost:8100/test to also map me to the view(index.html).
during the load of the page I am getting the following error:
the problem as you can see is that the url called is:
http://localhost:8100/static/css/main.6c417d20.chunk.css
and not
http://localhost:8100/test/static/css/main.6c417d20.chunk.css
(please note that the reason for the 'static' in the url is that there is a folder named: static below the resources/static folder so there is no issue with the 'static' in the url)
is it a server side problem or is it something I should fix in the react?
I searched for an answer but didn't find anything helpful.
any help would be highly appreciated,
Tnx
So the answer to my question lies in the following links:
how to build react to a non root path(homepage):
build react non root path
registering zuul client to the following path(that contains all resources):
Zuul configuration with resources
so I am leaving this here in case someone has the same issue(the answer in the second link is for vue.js and webpack,the first link explains how to change root address in react).
Answer 1 : #RequestMapping has a String[] value parameter, so can specify multiple values like this:
#RequestMapping(value={"", "/", "welcome"})
Answer 2 : You are expecting test in URL which is controller mapping not the project context path so it should not come in static resources urls.
see this answer for more clarity adding css and js in spring boot.
I'm trying to access some static resource in my visualforce page. I have uploaded a zip file named pqGrid. It's structure is like so:
- pqgrid.min.js
- pggrid.min.css
- images/
--image1.png
--image2.png
Following the directions in the sf docs on [referencing a static resource1, I tried the following:
<apex:includeScript value="{!URLFOR($Resource.pqGrid, 'pqgrid.min.js')}"/>
<apex:stylesheet value="{!URLFOR($Resource.pqGrid, 'pqgrid.min.css')}"/>
Onloading the page, I get a 404:
GET
https://c.cs10.visual.force.com/resource/7975978979000/pqGrid/pqgrid.min.js
404 (Not Found)
GET https://c.cs10.visual.force.com/resource/7975978979000/pqGrid/pqgrid.min.css
I've even tried just referencing an image:
<apex:image url="{!URLFOR($Resource.pqGrid, 'images/cross.png')}"/>
and same 404:
GET
https://c.cs10.visual.force.com/resource/7975978979000/pqGrid/images/cross.png
404 (Not Found)
I've made sure that the resource cache control is public
What am I doing incorrectly?
EDIT
Tried putting all the files into another directory, so it is now pqGrid/stash/[*files]
When I get the 404 not found:
GET
https://c.cs10.visual.force.com/resource/1430434594000/pqGrid/stash/pqgrid.min.css
I tried playing with this url. Trying to navigate to just /stash/ throws a ERR_INVALID_RESPONSE error. Navigating to just /pqGrid/ let's me download the stuff. Trying to go directly to the file, /pqGrid/stash/file.js I just get a blank page.
So the zip is definitely on salesforce, but something is up with accessing it.
Thanks all!
This happens when we specify incorrect paths for our files would suggest to try below
<apex:includeScript value="{!URLFOR($Resource.pqGrid, 'pqgrid/pqgrid.min.js')}"/>
<apex:stylesheet value="{!URLFOR($Resource.pqGrid, 'pqgrid/pqgrid.min.css')}"/>
Sometimes forgetting slash also introduces issues
<apex:includeScript value="{!URLFOR($Resource.pqGrid, '/pqgrid.min.js')}"/>
I've had a look to several similar problems on SO on this problems but I didn't find one which solves mine.
I'm following this tutorial to implement Google+'s Sign-in in my web application: https://blog.codecentric.de/en/2014/06/angularjs-google-sign-integration/
gapi is loaded correctly.
In my controller I have the following code:
gapi.signin.render('signInButton',
{
'callback': $scope.signInCallback, // Function handling the callback.
'clientid': '[MY_CLIENT_ID].apps.googleusercontent.com',
'requestvisibleactions': 'http://schemas.google.com/AddActivity',
'cookiepolicy': 'single_host_origin'
}
);
where
MY_CLIENT_ID is of course replaced by my actual client ID got from Google Dashboard.
I'm working on localhost:85 and "Javascript origin" is set exactly to http://localhost:85/
The error I'm getting is:
Refused to display ... in a frame because it set 'X-Frame-Options' to 'SAMEORIGIN'
NOTE: this error appears only sometimes. I don't understand why (the user interaction doesn't change, though).
I have the following function in my app_controller:
function beforeFilter() {
$this->set('lastThreePosts', $this->Blog->find_latest_posts());
}
I then use the variable 'lastThreePosts' that I have set in my layout. This works fine apart from on my 404 page where I get the following error:
Notice (8): Undefined index: lastThreePosts [APP\views\layouts\default.ctp, line 29]
I have made my own 404 page by created the file error404.ctp in my /views/errors/ directory.
So it seems when theres a 404 error the code in the controller doesn't get executed. Does anyone know how I can make it work?
Thanks
Phew! I found the answer here:
http://www.bradezone.com/2009/05/21/cakephp-beforefilter-and-the-error-error/