I have developed a few react webapps using Jhipster. Recently, I tried to start a new project. I cannot get new routes to load any of my components. This is something that I have been able to do very easily in the past (as earlier as two months ago). The page loads, but the body where the component should be isn't loaded. I have tried various approaches, and I'm stumped. Can anyone generate a simple test application and verify that adding new routes works? I appreciate your time.
I'm not sure if you solved this but I was having the same issue and what worked for me was to make sure that the route I was adding was above the route to "/" in the code.
Per this guide https://reactrouter.com/web/guides/primary-components routes should be ordered from more specific to less specific. I had my new route at the bottom of my route list in the code, but when I moved it above the "/" route definition, it worked.
Related
I want to publish my site on firebase hosting.
I'm using Static Generate in Next.js to create a page.
However, there are some pages that I want to do dynamic routing like a blog.
The URL looks like this "blog/[slug]"
If reloaded on a page other than the top page, it will be 404, so use next.config.
"Trailing Slash: true" is set.
When Dynamic Routing is performed with SG, the page has a file such as "blog/[slug]/index.html" exported.
Normally, it works fine for the transition from the top screen, but
If you reload with that URL, it will be 404.
One way to solve this is to detect that the blog is updated and rebuild it with WebHook etc. and deploy it.
There are various ways to do this on the website, but it is difficult to build each time because the update frequency is high.
Next, I'm thinking of doing CSR (Client Side Rendering) only for the blog part in the SG site.
Can't you route using a regular React Router? about it.
I tried to use React Router only for some pages, but I get an error because React Router is not a server side process.
Is the second thing I'm trying to do feasible?
If you have any other solutions to this problem, please let me know.
PS: Firebase Functions cannot be used due to a cold start issue...
Best regard.
It seems that it was solved just by entering the rewrite setting.
Thank you to everyone who saw the question.
"rewrites": [
{
"source": "/notice/**",
"destination": "/notice/[slug]/index.html"
}
For example, entering http://mywordpresswebsite.example.com/?json=1 into the browser loads the main site html, the same as omitting the json querystring variable: http://mywordpresswebsite.example.com/
The JSON API is activated. I have tried reactivating and deactivating, checking .htaccess file settings, and deactivating all other plugins. None of those have made much difference so far.
TIA
I had the same problem with my localhost test page and was wondering, why my route worked last week and was not accessible this week.
Short explanation
After some tests and a lot of frustration, I was able to use the REST API Route again by following the wordpress documentation about routes-vs-endpoints with “Pretty Permalinks” and “Ugly” Permalinks
Longer explanation
I guess in my case it was based on the reinstall of my MySQL Database. By installing the new database, my previous setup has been reset to the wordpress standard installation with permalinks as "plain", which is an "ugly" permalink. That's the reason, why the answer of Mattygabe work for me after the reinstall of the database.
But with this solution, I had a problem with my filter value and therefore I found the solution with "pretty premalinks" and changed my permalinks to "Month and name", as shown in the picture. After this change, I could access my REST API via the desired route.
There could be also some difficulties with REST APIs related to the following examples:
using "wp" within the REST route
if you work on plugins, which should be shared, keep on mind that some plugins may restrict REST Access, e.g. iThemes Security
I'm likely doing it wrong, but when I form my requests for a Wordpress installation at http://www.example.com/ like this:
http://www.example.com/index.php?rest_route=/my/rest/route/here
I end up getting proper responses back.
I had a heck of a time figuring this out and ended up grokking a URL formatted like that in the HTML returned to me. I was expecting to make requests as http://www.example.com/wp_json/wp/v2/my/rest/route/here , but I only got HTML responses.
(FWIW, I am reposting this on all similar questions on the StackExchange network. Admins/mods - if this is against the rules or seen as rep spamming, feel free to take it down. Was hoping to help anyone else hitting the same issue I am, and to also learn what it is I've done wrong and why.)
Ok, so the new endpoint for Wordpress 4.7 is mywordpresswebsite.example.com/index.php/wp-json. It's part of Wordpress Core as of 4.7 and not a plugin anymore, there's nothing to be activated. Thank you, Mark Kaplun.
I also experienced this issue. I did install the WP API plugin and then realized I didn't need it so I deactivated it and deleted it. Afterwards I tried a GET request to https://example.com/wp-json/wp/v2/posts and received the HTML of my wordpress site.
To fix this I ended up deactivating all plugins and then I started receiving the JSON response from https://example.com/wp-json/wp/v2/posts so I stepped through each plugin reactivating and in the end all my plugins are active and the endpoint is responding with JSON.
I changed Permalinks (Settings => Permalinks)
I had an issue returning html page instead of JSON response on Wordpress 5.3 and I got resolved when I changed the Permalink as Post name from plain
Following the instructions on the MEAN.js website, I create a new site and attempt to create a new CRUD using yeoman generator. my command is as follows
$ yo meanjs:crud-module meal
Everything seems to be created correctly in the modules folder, and when I go tho the site, and attempt to create a new "meal" everything seems to work fine until I hit submit. The browser throws the following error
http://localhost:3000/meals/api/meals 404 (Not Found)
Am I missing a step in the setup? is there something additional I need to do to get CRUD to work.
There is something wrong with your routing, check your client/config/routes and server/routes file. The URL should be:
http://localhost:3000/api/meals
without the first meals after 3000. That's why it is a 404.
Hope this helps, if you cant find the problem add some code.
Just put a forward slash(/) in front of api in resource service.
/api/meals instead of api/meals
I've come across an issue which I've been trying to figure whether I'm just doing something wrong or whether it's an actual bug. After a lot of searching, I still can't figure out if I'm doing something wrong or if I've found an actual problem.
Part of the reason as to why I'm so confused is also because I found the intersection between react-router and history a bit confusing. It took me a while to figure out exactly how to use history's enhancer functions with react-router and I still think the issue might lay there.
I have a test case here:
https://github.com/trodrigues/react-router-basename-test
http://trodrigues.github.io/react-router-basename-test/
And the problem is:
Clicking the button issues a this.context.router.push call to navigate to /content/path
I'd expect it to navigate to http://trodrigues.github.io/react-router-basename-test/content/path
Instead it navigates to http://trodrigues.github.io/react-router-basename-test/react-router-basename-test/content/path
Some additional detail:
If I use the <base> tag instead of the useBasename enhancer this works fine. However, given that I have a slightly different setup for dev and production, using an environment variable to define the basepath would be more helpful, rather than manipulating the <base> tag at build time.
The sample app I uploaded is a minimal subset of the app I'm working on. I removed everything else that didn't matter.
The issue does not occur when running this locally with a basepath set to an empty string.
After some further investigation I figured out react-router already uses the useBasename enhancer when using useRouterHistory, which is the cause of the problem as the enhancer gets executed twice.
I will refer to the account as user in this post.
So I put the tcpdf directory in /home/user/laravel/
I then tried to do this in a page:
{{ HTML::link('/tcpdf/examples/example_001.php') }}
and I get the 404 requested page that I setup
any ideas why this is happening or why its not working?
Do I need to do a route maybe?
Any information on this would be great.
If you are really trying to work with TCPDF within your Laravel app, you will most likely want to include it as you would other packages using composer. Please see this answer on how to add TCPDF to composer.json in order to have composer automatically download it into your vendor area: Download tcpdf manually without using composer in Laravel 4 (Ignore the post title - it does talk about including TCPDF with composer.)
What you are achieving with the code sample above is to simply render a link to a certain URI off your URL base. Whether or not that will work will depend on how your local web server is configured and potentially how Laravel and Laravel routing is configured.
Having said all that, I think you are headed down the wrong path with that solution. Ultimately, I believe that what you will want to do is drag TCPDF in using composer, then create a PDF file with code like:
$pdf = new TCPDF();
$pdf->AddPage();
$pdf-> ... other stuff according to the TCPDF API...
$pdf->Output( 'test.pdf', 'I' );
The TCPDF API can be found here: http://www.tcpdf.org/doc/code/classTCPDF.html
You could put some code like that into a controller method to play around and get things working, but later you would probably want to move it elsewhere.