Merge pull request 'fix: sempre problemi con BASE_URL' (#11) from dev into main
continuous-integration/drone/push Build is passing
continuous-integration/drone/push Build is passing
Reviewed-on: #11
This commit was merged in pull request #11.
This commit is contained in:
+1
-1
@@ -1,3 +1,3 @@
|
|||||||
|
|
||||||
BASE_URL=/
|
BASE_URL=/problemi/
|
||||||
DATABASE_PATH=db.local.json
|
DATABASE_PATH=db.local.json
|
||||||
+1
-1
@@ -30,7 +30,7 @@ import { UserPage } from './pages/UserPage'
|
|||||||
|
|
||||||
export const App = ({ url }: { url?: string }) => {
|
export const App = ({ url }: { url?: string }) => {
|
||||||
// during server side rendering don't prepend the BASE_URL
|
// during server side rendering don't prepend the BASE_URL
|
||||||
const pbu = useContext(ServerContext) ? (s: string) => s : prependBaseUrl
|
const pbu = prependBaseUrl
|
||||||
|
|
||||||
const handleRouteChange = () => {
|
const handleRouteChange = () => {
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
|
|||||||
@@ -98,8 +98,8 @@ async function createProductionRouter(db: DatabaseConnection) {
|
|||||||
res.send(finalHtml)
|
res.send(finalHtml)
|
||||||
}
|
}
|
||||||
|
|
||||||
r.get('/', handleSSR)
|
r.get(process.env.BASE_URL ?? '/', handleSSR)
|
||||||
r.use('/', express.static('dist/entry-client'))
|
r.use(process.env.BASE_URL ?? '/', express.static('dist/entry-client'))
|
||||||
|
|
||||||
r.use('*', handleSSR)
|
r.use('*', handleSSR)
|
||||||
|
|
||||||
@@ -113,12 +113,12 @@ async function main() {
|
|||||||
|
|
||||||
const [r, db] = await createApiRouter()
|
const [r, db] = await createApiRouter()
|
||||||
|
|
||||||
app.use('/', r)
|
app.use(process.env.BASE_URL ?? '/', r)
|
||||||
|
|
||||||
if (config.isDevelopment) {
|
if (config.isDevelopment) {
|
||||||
app.use('/', await createDevRouter(db))
|
app.use(process.env.BASE_URL ?? '/', await createDevRouter(db))
|
||||||
} else {
|
} else {
|
||||||
app.use('/', await createProductionRouter(db))
|
app.use(process.env.BASE_URL ?? '/', await createProductionRouter(db))
|
||||||
}
|
}
|
||||||
|
|
||||||
app.listen(config.port, () => {
|
app.listen(config.port, () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user