My front theme opened, there is no problem with that but it gives me this error when i opened admin theme... Here is my codes;
Route file;
Route::prefix('admin')->group(function () {
Route::get('/','AdminController#getIndex'); });
and controller;
public function getIndex(){
return view('back.index'); }
Where do i make mistakes ?
I had this problem and it was that I had a route going to '/admin' and a folder within my public folder called 'admin'.
So NGINX was first trying to go into the 'admin' directory before it got to render the routes, which since there wasn't an index.php in the admin directory, it gave the error.
Related
I have a nextjs project hosted on the vercel, and I am facing issue that when I reload some path (ex. /blogs) it returns 404. But, when I first access to the path, there is no problem and just show exactly what I want.
Path that I want to access is /blogs and directory structure is simply as below.
pages
- blogs.tsx
and my blogs.tsx are using getStaticPros to get all blog mdx files.
import { GetStaticProps } from 'next'
import React from 'react'
import { Blogs } from '#component/blogs'
import BlogsType from '#src/types/blog'
import { getAllBlogs } from '#utils/blog/getAllPosts'
type BlogStaticInputs = {
blogs: BlogsType[]
}
export const Index = ({ blogs }: BlogStaticInputs) => {
return <Blogs blogs={blogs} />
}
// get all blogs data from './blogs'
export const getStaticProps: GetStaticProps = async () => {
const blogs = getAllBlogs([
'date',
'description',
'slug',
'title',
'author',
'image',
'sns',
'username'
])
return {
props: { blogs },
revalidate: 10
}
}
export default Index
As I explained, it perfectly works on the first visit, but it fails on reload or after first visit on refresh.
I did some research and I found I should add trailingSlash:true on the next.config.js config file but it didn't solve my problem.
The error message is simpley Failed to load resource: the server responded with a status of 404 (). I am wondering why this happens since it just works locally (localhost) but suddenly fails on vercel preview url.
I think you should try building the app first on local environment via npm run build and check for blog.json file response in network tab because sometimes it does get 404 on .json file and still works that becomes problem on vercel later on.
I had a very similar issue.
Removing the revalidate has solved it for me. For me i had revalidate every 36000 seconds, and i noticed my site was failing after exactly 10hours (36000s). For you it seems is 10 seconds, so you visit once, you get the cached files, and the second time nextjs tries to get the new data from the api.
Unfortunately I don't know why it fails, i just know that it will fix it. But you wont have ISR anymore you'll have just SSG.
I'll edit my answer once i find the culprit.
Hope it helps.
I know there have been a few of these posts but i've looked through all that ive found and tried their solutions without success and im getting a bit desperate now. This needs to be finished by the end of tomorrow.
Im building a website that uses a MySQL db and Web API 2 on Entity Framework at the backend, then js/jax on the front end, all hosted on Azure.
I was making some more HTML pages, nothing to do with any of the config files, then I random started getting this error.
XMLHttpRequest cannot load https://uocfabianwiles.azurewebsites.net/api/Courses. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:56401' is therefore not allowed access. The response had HTTP status code 500.
Im using the below code to enable CORS
var cors = new EnableCorsAttribute("*", "*", "*");
config.EnableCors(cors);
None of the https requests through Swagger return me with anything but an error, yet they were working fine this morning.
What i've tried:
Adding this to the controllers, as per http://enable-cors.org/server_aspnet.html
[EnableCors(origins: "http://msauocfabianwiles.azurewebsites.net/api/students", headers: "*", methods: "*")]
Adding custom headers to to the web.config file
Changing databases
Reinstalling Entity and MySQL Nuget packages
Running locally with debugging in Visual Studio - no errors from VS
Edit: I tried deleting the DB/website and made new ones, that somehow resolved the CORS error but instead is now giving me a 500 Internal Server Error, but only maybe 70% of the time, the other 30% it loads fine without issues
I used to have this error but I solved it by using the code below.
using Microsoft.Owin;
using Microsoft.Owin.Cors;
using Owin;
[assembly: OwinStartup(typeof(MyProject.Api.Startup))]
namespace MyProject.Api {
public class Startup {
public void Configuration(IAppBuilder app) {
app.UseCors(CorsOptions.AllowAll);
}
}
}
Hope it works. If not, Try config.EnableCors(); (without attribute) in WebApiConfig.
Example:
public static class WebApiConfig
{
public static void Register(HttpConfiguration config)
{
// Web API configuration and services
config.EnableCors();
// Web API routes
config.MapHttpAttributeRoutes();
config.Routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "api/{controller}/{id}",
defaults: new { id = RouteParameter.Optional }
);
}
}
Hope it helps.
I am building a website, in which I want to have a static html to be served when root of the application is accessed and when an action is specified, it need to redirect to appropriate controller.
For instance, www.abc.com has index.html at its root folder, the index.html has to be served when user types www.abc.com, which will have links to other pages like www.abc.com/home/index
I am hosting this in windows azure websites, so IIS configuration may not be possible. Is there any other way to ignore particular scenario using route table or other means?
Create separate Action and its view. The same action will be your default root.
public ActionResult StartIndex()
{
return View();
}
inside view StartIndex.cshtml you can write script as shown below
#{ Layout=null; }
<script>
$(document).ready(function(){
window.location.href='www.abc.com';
});
</script>
It may helps you.
I got this solved by removing the default controller in routes table.
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { action = "Index", id = UrlParameter.Optional }
);
Now unless a controller is specified, it is launching the index.html
I'm trying to get something very simple to work with node.js and im kind of stuck at the moment . Hoping someone could help me out with this problem.. Im trying a very simple node.js application.. Basically there is a index.html file which has a form with name as a parameter.. onclick of the button calls a JQuery script which performs a POST request to a node.js script with the NAME value obtained from the html form..
Now the post request is made to the node.js script which runs a HTTP server on its default port.. All that the node.js script does is accepts the parameter and replies with a very trivial response which includes the POST parameter which was sent.. This reponse is caught by JQuery and is given to the user using alert..
So i have index.html and login.js as my two scripts.. Now Im using heroku to host these files.. Problem is once they're uploaded it doesnt really open the html file by default.. it runs the login.js by default..So the HTML is never opened.. Thats probably cause I have a procfile which loads login.js to the dyno.. But if i remove the procfile then i get an error in the logs saying "No web processes running" ..
So basically, long story short , is there a way to have an index.html and a node.js file running on the same heroku instance where the html requests the node.js for info and returns it back..
Here are links to my html and node.js scripts
https://dl.dropbox.com/u/904687/index.html
https://dl.dropbox.com/u/904687/login.js
One option is to use Node.js Express.js to serve the html file and then also handle the login route.
The whole thing would look something like.
file : package.json
{
"name" : "LoginPage",
"version" : "0.0.1",
"dependencies" : {
"express" : "3.x"
},
"main" : "index.js"
}
file : index.js
var express = require('express');
var app = express();
var oneDay = 86400000;
app.use(express.compress());
app.use(express.static(__dirname + '/public', { maxAge: oneDay }));
app.use(express.bodyParser());
app.listen(process.env.PORT);
app.post('/', function(req, res){
var result = req.rawBody;
res.send("hello there world data is " + result);
});
directory structure
package.json
index.js
public
index.html
I need to let users of an application open a folder by clicking a link inside a web page. The path of the folder is on the network and can be accessed from everywhere. I'm probably sure there is no easy way to do this, but maybe I'm mistaken?
Do you want to open a shared folder in Windows Explorer? You need to use a file: link, but there are caveats:
Internet Explorer will work if the link is a converted UNC path (file://server/share/folder/).
Firefox will work if the link is in its own mangled form using five slashes (file://///server/share/folder) and the user has disabled the security restriction on file: links in a page served over HTTP. Thankfully IE also accepts the mangled link form.
Opera, Safari and Chrome can not be convinced to open a file: link in a page served over HTTP.
The URL file://[servername]/[sharename] should open an explorer window to the shared folder on the network.
Using file:///// just doesn't work if security settings are set to even a moderate level.
If you just want users to be able to download/view files* located on a network or share you can set up a Virtual Directory in IIS. On the Properties tab make sure the "A share located on another computer" is selected and the "Connect as..." is an account that can see the network location.
Link to the virtual directory from your webpage (e.g. http://yoursite/yourvirtualdir/) and this will open up a view of the directory in the web browser.
*You can allow write permissions on the virtual directory to allow users to add files but not tried it and assume network permissions would override this setting.
A bit late to the party, but I had to solve this for myself recently, though slightly different, it might still help someone with similar circumstances to my own.
I'm using xampp on a laptop to run a purely local website app on windows. (A very specific environment I know). In this instance, I use a html link to a php file and run:
shell_exec('cd C:\path\to\file');
shell_exec('start .');
This opens a local Windows explorer window.
make sure your folder permissions are set so that a directory listing is allowed then just point your anchor to that folder using chmod 701 (that might be risky though)
for example
<a href="./downloads/folder_i_want_to_display/" >Go to downloads page</a>
make sure that you have no index.html any index file on that directory
What I resolved doing is installing a local web service on every person's computer that listens on port 9999 for example and opens a directory locally when told to. My example node.js express app:
import { createServer, Server } from "http";
// server
import express from "express";
import cors from "cors";
import bodyParser from "body-parser";
// other
import util from 'util';
const exec = util.promisify(require('child_process').exec);
export class EdsHelper {
debug: boolean = true;
port: number = 9999
app: express.Application;
server: Server;
constructor() {
// create app
this.app = express();
this.app.use(cors());
this.app.use(bodyParser.json());
this.app.use(bodyParser.urlencoded({
extended: true
}));
// create server
this.server = createServer(this.app);
// setup server
this.setup_routes();
this.listen();
console.info("server initialized");
}
private setup_routes(): void {
this.app.post("/open_dir", async (req: any, res: any) => {
try {
if (this.debug) {
console.debug("open_dir");
}
// get path
// C:\Users\ADunsmoor\Documents
const path: string = req.body.path;
// execute command
const { stdout, stderr } = await exec(`start "" "${path}"`, {
// detached: true,
// stdio: "ignore",
//windowsHide: true, // causes directory not to open sometimes?
});
if (stderr) {
throw stderr;
} else {
// return OK
res.status(200).send({});
}
} catch (error) {
console.error("open_dir >> error = " + error);
res.status(500).send(error);
}
});
}
private listen(): void {
this.server.listen(this.port, () => {
console.info("Running server on port " + this.port.toString());
});
}
public getApp(): express.Application {
return this.app;
}
}
It is important to run this service as the local user and not as administrator, the directory may never open otherwise.
Make a POST request from your web app to localhost: http://localhost:9999/open_dir, data: { "path": "C:\Users\ADunsmoor\Documents" }.
Does not work in Chrome, but this other answers suggests a solution via a plugin:
Can Google Chrome open local links?
You can also copy the link address and paste it in a new window to get around the security. This works in chrome and firefox but you may have to add slashes in firefox.
Hope it will help someone someday. I was making a small POC and came across this.
A button, onClick display contents of the folder. Below is the HTML,
<input type=button onClick="parent.location='file:///C:/Users/' " value='Users'>
I was looking for File System Access API and ended up in this question.
I know that API doesn't allow one to open an html link to a folder, but it does allow for opening local folders and files. For more information, take a look here:
https://web.dev/file-system-access/