CORS has been defeated, as my sanity...

This commit is contained in:
Max 2024-11-04 23:12:51 +03:00
parent 0aa9f78d07
commit 2398d3ebc0
7 changed files with 178 additions and 1014 deletions

View File

@ -1,23 +1,36 @@
import "./App.css"; import "./App.css";
import "@radix-ui/themes/styles.css"; import "@radix-ui/themes/styles.css";
import { import { Theme, ThemePanel } from "@radix-ui/themes";
Theme,
ThemePanel,
} from "@radix-ui/themes";
import { import { createBrowserRouter, RouterProvider } from "react-router-dom";
createBrowserRouter,
RouterProvider,
} from "react-router-dom";
import { QueryClientProvider } from "@tanstack/react-query"; import { QueryClientProvider } from "@tanstack/react-query";
import queryClient from "./api/QueryClient/QueryClient"; import queryClient from "./api/QueryClient/QueryClient";
import { routes } from "./routes/routes"; import { routes } from "./routes/routes";
import { useEffect } from "react";
import "axios";
import { axiosLocalhost } from "./api/axios/axios";
const router = createBrowserRouter( const router = createBrowserRouter(routes);
routes
);
export default function App() { export default function App() {
useEffect(() => {
let f = async () => {
let c = await axiosLocalhost.post(
"/login",
{
nickname: "StasikChess",
password: "123456",
}
);
console.log(c.headers);
console.log(document.cookie);
};
f();
}, []);
return ( return (
<Theme className="h-fit" accentColor="indigo" grayColor="slate"> <Theme className="h-fit" accentColor="indigo" grayColor="slate">
<QueryClientProvider client={queryClient}> <QueryClientProvider client={queryClient}>

View File

@ -1,12 +1,23 @@
import React from 'react' import React from 'react'
import { Outlet } from 'react-router-dom' import { Outlet } from 'react-router-dom'
import NavBar from '../../Components/NavBar/NavBar' import NavBar from '../../Components/NavBar/NavBar'
import { axiosLocalhost } from '../../api/axios/axios'
export default function MainPage() { export default function MainPage() {
return ( return (
<> <>
<NavBar /> <NavBar />
<Outlet /> <Outlet />
<button
onClick={
async () => {
let d = await axiosLocalhost.get("getCookie")
console.log(d.data);
}
}>
qwpofjqwifhqwuif
</button>
</> </>
) )
} }

View File

@ -0,0 +1,13 @@
import axios from "axios";
export const axiosLocalhost = axios.create(
{
baseURL: `http://localhost:9876/`,
withCredentials: true,
headers: {
}
}
)
axios.defaults.withCredentials = true;

View File

@ -45,5 +45,7 @@ func main() {
return return
} }
router.Run("localhost:9876")
fmt.Printf("Hey!, %v", "you") fmt.Printf("Hey!, %v", "you")
} }

File diff suppressed because it is too large Load Diff

102
package-lock.json generated
View File

@ -5,7 +5,8 @@
"packages": { "packages": {
"": { "": {
"dependencies": { "dependencies": {
"@tanstack/react-query": "^5.59.0" "@tanstack/react-query": "^5.59.0",
"axios": "^1.7.7"
} }
}, },
"node_modules/@tanstack/query-core": { "node_modules/@tanstack/query-core": {
@ -34,6 +35,78 @@
"react": "^18 || ^19" "react": "^18 || ^19"
} }
}, },
"node_modules/asynckit": {
"version": "0.4.0",
"resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz",
"integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==",
"license": "MIT"
},
"node_modules/axios": {
"version": "1.7.7",
"resolved": "https://registry.npmjs.org/axios/-/axios-1.7.7.tgz",
"integrity": "sha512-S4kL7XrjgBmvdGut0sN3yJxqYzrDOnivkBiN0OFs6hLiUam3UPvswUo0kqGyhqUZGEOytHyumEdXsAkgCOUf3Q==",
"license": "MIT",
"dependencies": {
"follow-redirects": "^1.15.6",
"form-data": "^4.0.0",
"proxy-from-env": "^1.1.0"
}
},
"node_modules/combined-stream": {
"version": "1.0.8",
"resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz",
"integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==",
"license": "MIT",
"dependencies": {
"delayed-stream": "~1.0.0"
},
"engines": {
"node": ">= 0.8"
}
},
"node_modules/delayed-stream": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz",
"integrity": "sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==",
"license": "MIT",
"engines": {
"node": ">=0.4.0"
}
},
"node_modules/follow-redirects": {
"version": "1.15.9",
"resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.9.tgz",
"integrity": "sha512-gew4GsXizNgdoRyqmyfMHyAmXsZDk6mHkSxZFCzW9gwlbtOW44CDtYavM+y+72qD/Vq2l550kMF52DT8fOLJqQ==",
"funding": [
{
"type": "individual",
"url": "https://github.com/sponsors/RubenVerborgh"
}
],
"license": "MIT",
"engines": {
"node": ">=4.0"
},
"peerDependenciesMeta": {
"debug": {
"optional": true
}
}
},
"node_modules/form-data": {
"version": "4.0.1",
"resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.1.tgz",
"integrity": "sha512-tzN8e4TX8+kkxGPK8D5u0FNmjPUjw3lwC9lSLxxoB/+GtsJG91CO8bSWy73APlgAZzZbXEYZJuxjkHH2w+Ezhw==",
"license": "MIT",
"dependencies": {
"asynckit": "^0.4.0",
"combined-stream": "^1.0.8",
"mime-types": "^2.1.12"
},
"engines": {
"node": ">= 6"
}
},
"node_modules/js-tokens": { "node_modules/js-tokens": {
"version": "4.0.0", "version": "4.0.0",
"resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz",
@ -54,6 +127,33 @@
"loose-envify": "cli.js" "loose-envify": "cli.js"
} }
}, },
"node_modules/mime-db": {
"version": "1.52.0",
"resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz",
"integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==",
"license": "MIT",
"engines": {
"node": ">= 0.6"
}
},
"node_modules/mime-types": {
"version": "2.1.35",
"resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz",
"integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==",
"license": "MIT",
"dependencies": {
"mime-db": "1.52.0"
},
"engines": {
"node": ">= 0.6"
}
},
"node_modules/proxy-from-env": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.1.0.tgz",
"integrity": "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==",
"license": "MIT"
},
"node_modules/react": { "node_modules/react": {
"version": "18.3.1", "version": "18.3.1",
"resolved": "https://registry.npmjs.org/react/-/react-18.3.1.tgz", "resolved": "https://registry.npmjs.org/react/-/react-18.3.1.tgz",

View File

@ -1,5 +1,6 @@
{ {
"dependencies": { "dependencies": {
"@tanstack/react-query": "^5.59.0" "@tanstack/react-query": "^5.59.0",
"axios": "^1.7.7"
} }
} }